Trying to change the background of a QTreeWidget
After a lot of searching, I'm gonna ask :)
I have a QTreeWidget on a dialog. The user requirement is that the background of the tree is the same color as QPalette::Window (and the palette can change, so just modifying the palette in designer won't work). I've tried tree->setBackgroundRole(QPalette::Window) (and even foreground role)... no difference.
If I modify the items (item->setBackground(QApplication::palette().window()) ), the item backgrounds are right... but the tree widget w/o items is still white (base).
Using qt 4.3.2 --- and ready to tear my hair out, since this seems to function in other places, just not the tree widget.
Vycke
Re: Trying to change the background of a QTreeWidget
from the docs :
Quote:
QPalette::ColorRole
QPalette::Background Window This value is obsolete. Use Window instead.
also try tree->viewport()->setPallete() if the color doesnt work
also try using setAutoFillBackground() function while setting the color.
Hope this helps :)
Re: Trying to change the background of a QTreeWidget
Quote:
Originally Posted by
aamer4yu
from the docs :
also try tree->viewport()->setPallete() if the color doesnt work
also try using setAutoFillBackground() function while setting the color.
Hope this helps :)
Ok, it works with:
tree->viewport()->setBackgroundRole(QPalette::Window);
Woot! :)
Thanks,
Vycke