Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Different styles for qtreewidgetitem 's of the same qtreewidget
I need to set different colors for different levels of hierarchy in a tree widget.
It seems stylesheet affects all items the same way with no ability to distinguish them some way - unless for their states.
qtreewidgetitem class has no object name property either.
Does it exist a reasonably fast way to do it?
Why not simply set the background color programatically?
I need to set the entire style. By the way if I set a default style by style sheet it causes qt to ignore setBackgroundColor.
qt to ignore setBackgroundColor.
Yes, that's by design: Style sheets are applied on top of the current widget style,
JonB last edited by JonB
https://stackoverflow.com/questions/13074643/qtreewidget-applying-styles-for-items says you cannot achieve this via Qt stylesheet. Just letting you know.
QTreeWidgetItem::data()when role is
Back/ForegrondRolebe used for setting your color?
Thank you. I need to set different style : border colors, background, foreground and so on.
Ok so there's no solution. good to know.
JonB last edited by
You can go down to styled item delegate level. https://stackoverflow.com/questions/27273839/set-qitemdelegate-on-a-particular-qtreewidgetitem talks about this. But I think you'd really rather do that by stylesheet, right? And I don't think you can.
Black Imp last edited by Black Imp
@JonB thank you. I think I'll try to manage different look just with background and foreground colors, via code.