Unsolved 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?thank you
-
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.
-
@Black-Imp said in Different styles for qtreewidgetitem 's of the same qtreewidget:
qt to ignore setBackgroundColor.
Yes, that's by design: Style sheets are applied on top of the current widget style,
-
@Black-Imp
https://stackoverflow.com/questions/13074643/qtreewidget-applying-styles-for-items says you cannot achieve this via Qt stylesheet. Just letting you know.Could
QTreeWidgetItem::data()
when role isBack/ForegrondRole
be used for setting your color? -
@JonB said in Different styles for qtreewidgetitem 's of the same qtreewidget:
QTreeWidgetItem::data(
Thank you. I need to set different style : border colors, background, foreground and so on.
Ok so there's no solution. good to know. -
@Black-Imp
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. -
@JonB thank you. I think I'll try to manage different look just with background and foreground colors, via code.