Is there anyone knows how to set the background color of different itmes in QTreeView?Thanks very much
Is there anyone knows how to set the background color of different itmes in QTreeView?Thanks very much
in general you can use Qt::BackgroundRole, but if you use QStandardItemMode & QStandardItem then you can use this method QStandardItem::setBackground or you also can create your own delegate and reimplement QItemDelegate::drawBackground.
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
another way would be to use stylesheet. The following should work:
QTreeView::item
{
background-color: #your color
}
If you want to use background color to differentiate items, you can also have a look at QAbstractItemView::setAlternatingRowColors
Bookmarks