Using QListView and QStandardItemModel, is it possible to display icons in a list view without displaying related text? QStandardItem is defined like this:
QStandardItem ( const QIcon & icon, const QString & text )
So it seems like some kind of text string is required - I want the icon to display. If I use the following code, I get icons on demand, but I also get an empty text element below them. I do not want it.
ImageListView->setViewMode( QListView::IconMode ); { QStandardItemModel *iStandardModel = new QStandardItemModel(this); QStandardItem* item1 = new QStandardItem(QIcon("images/shield-280x280.png"),""); QStandardItem* item2 = new QStandardItem(QIcon("images/shield-280x280.png"),""); iStandardModel->appendRow(item1); iStandardModel->appendRow(item2); ImageListView->setIconSize(QSize(100,100)); ImageListView->setUniformItemSizes(true); ImageListView->setDragDropMode(QAbstractItemView::DropOnly); ImageListView->setModel(iStandardModel); }
If I run into the problem of creating a custom model, can I solve this problem?
c ++ qt qlistview
Chris k
source share