Is somehow possible to add icons to a ListView using a QStringListModel ?
This is what I'm doing.
QStringListModel* model;
QStringList List;
model->setStringList(List);
ui->listView->setModel(model);
...
model->setData(index, "Test");
model->setData(index,QIcon(":/icon.png"),Qt::DecorationRole);
unfortunately the icon does not appears on the list.
How can I add icons to the list?
QStringListModeldoes not support roles other thanDisplayRoleandEditRole.Use
QStandardItemModelinstead in order to display icons viaDecorationRole: