开发者

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
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜