Draw tick mark in QTree
I want to draw a tick mark in a Qtreeview. I don't want to have a checkbox but just to indicate an item. Is there a way to do so? 开发者_运维百科
Thanks
In your model's data() function, return a QIcon or QPixmap for the Qt::DecorationRole:
QVariant MyItemModel::data(const QModelIndex &index, int role) const
{
...
if(role==Qt::DecorationRole)
{
if(currentItem.isChecked()) return QPixmap(":my_check_icon.png") // Checkmark Image
else return QVariant(); // No checkmark
}
}
精彩评论