PDA

View Full Version : QTreeWidgetItem: reset background color



supergillis
3rd August 2008, 11:19
How do you reset the background of a QTreeWidgetItem?
I know how to set the background to another color - setBackground(0, QColor(202, 224, 232, 255)); - but putting it back? :confused:

jpn
3rd August 2008, 11:38
Try:

item->setBackground(column, QBrush());

supergillis
3rd August 2008, 12:23
Works like a charm :)
Thanks!

supergillis
3rd August 2008, 12:46
But now, when using sorted QTreeWidget, the item with another brush gets sorted in front.
Example:
I got a music list. That list contains songs of AC/DC. You got the song 'Thunderstruck' and 'Back in Black'. When you order the tree on artist, and you play the song 'Thunderstruck' it changes the background color to green and 'Thunderstruck' suddenly pops in front of 'Back in Black'... If you know what I mean...

I tried resorting after changing the brush but that doesn't make any difference.

jpn
3rd August 2008, 13:12
Could you prepare a minimal compilable example which reproduces the problem?