PDA

View Full Version : Changing the text color of a QTreeView leaf.



johnny_sparx
22nd March 2006, 21:44
Hello, my QTreeView needs to have its tree leaves' colors changed based on some flag settings. How do I do this? I wish to iterate through the entire tree (already set up from a model), check the flags, and change the childless items red where the flag setting is true.

I guess I simply do not know how to access the QTreeWidgetItem so that I may change its properties. Is this possible? Am I stuck with the default colors with QTreeView?

John.

wysota
22nd March 2006, 23:18
Set colours in the model by using setData() and Qt::BackgroundColorRole or Qt::TextColorRole depending on which colour you want to change.

johnny_sparx
22nd March 2006, 23:48
But how do I get the required QModelIndex?

wysota
22nd March 2006, 23:58
Using QAbstractItemModel::index().