PDA

View Full Version : Colors of QTreeView



slava
28th September 2008, 20:21
Hello all!
I have a QStandardItemModel getting filled with the data and then dispalyed in QTreeView in a form. I would need to highlight few lines with a red color in that TreeView, let's say all lines which starts with A and the other lines remain black. I can't find color property neither in QStandardItemModel nor in QTreeView. Is it possible to make raws of different colors like this?:confused:

jacek
28th September 2008, 20:26
See QStandardItem::setBackground().

slava
28th September 2008, 22:01
Thank you. But I still think I'm missing something. It says "QAbstractItemModel has no member named setBackground"

jacek
28th September 2008, 22:08
Yes, but it has the data() and setData() methods and Qt::BackgroundColorRole. You can also implement your own item delegate and add a setBackground() method to it.