#include <QtGui>
int main(int argc, char * argv[])
{
model
->setData
(model
->index
(0,
0), lv
->style
()->standardIcon
(QStyle::SP_BrowserReload), Qt
::DecorationRole);
model->setData(model->index(0, 0), "Hello World!", Qt::DisplayRole);
model
->setData
(model
->index
(1,
0), lv
->style
()->standardIcon
(QStyle::SP_FileIcon), Qt
::DecorationRole);
model->setData(model->index(1, 0), "Goodbye World!", Qt::DisplayRole);
lv->setModel(model);
lv->show();
return a.exec();
}
#include <QtGui>
int main(int argc, char * argv[])
{
QApplication a(argc, argv);
QStandardItemModel * model = new QStandardItemModel(2, 1);
QListView * lv = new QListView(0);
model->setData(model->index(0, 0), lv->style()->standardIcon(QStyle::SP_BrowserReload), Qt::DecorationRole);
model->setData(model->index(0, 0), "Hello World!", Qt::DisplayRole);
model->setData(model->index(1, 0), lv->style()->standardIcon(QStyle::SP_FileIcon), Qt::DecorationRole);
model->setData(model->index(1, 0), "Goodbye World!", Qt::DisplayRole);
lv->setViewMode(QListView::IconMode);
lv->setModel(model);
lv->show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks