Hi,
I successfully created a QListView but QStandardItems don't get shown properly.
The yellow style is a verification of the QListViews existence.Code:ui->graphicsView->setGeometry(361,0,360,640); appsListView = new QListView(ui->centralWidget); appsListView->setGeometry(0,0,360,640); //ui->centralWidget->setStyleSheet("QListView { background-color: yellow }"); appsItemModel = new QStandardItemModel(); QStandardItem appItem(QString("app")); appItem.setData(QString("uid")); appItem.setForeground(QBrush(QColor(255,255,255))); appsItemModel->setItem(0,&appItem); appsListView->setModel(appsItemModel); configureFor = key; appsListView->show(); connect(appsListView, SIGNAL(clicked(QModelIndex)), this, SLOT(appItemClicked(QModelIndex)));
I can even select the first and only item as its selection highlight is shown when clicking at the top of the screen, but it doesn't show text. Also the application crashes when clicking the first item.
What's the issue here? What do I have to do to get the QStandardItem displayed properly?Code:void MainWindow::appItemClicked(const QModelIndex &index) { //QStandardItem* item = appsItemModel->itemFromIndex(index); //ui->label->setText(item->data().toString()); disconnect(appsListView, SIGNAL(clicked(QModelIndex)), this, SLOT(appItemClicked(QModelIndex))); appsListView->hide(); delete appsListView; delete appsItemModel; ui->graphicsView->setGeometry(0,0,360,640); }



