I have my own subclass of QListView and I would like to change the color of an item with index mLastIndex . I tried with
QModelIndex vIndex = model()->index(mLastIndex,0) ;
QMap<int,QVariant> vMap;
vMap.insert(Qt::ForegroundRole, QVariant(QBrush(Qt::red))) ;
model()->setItemData(vIndex, vMap) ;
But it didn't change the color, instead, the item wasn't displayed anymore. Any idea about what was wrong?