I’m building a custom QAbstractItemModel model.
The first column contains icons, the second one – text.
This is the code of the data method:
QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const
{
if(role != Qt::DisplayRole )
return QVariant();
int col = index.column();
if (col == 0)
{
return iconProvider->icon(QFileIconProvider::Folder);
}
else if (col == 1)
{
return "TEXT";
}
}
But all I get in the resulting Table View is just text in the second column. There’s no folder icon in the first column.
Am I missing something here?
Qt::DisplayRoleis only for text. Add: