PDA

View Full Version : Why can't I set backgroung of a QTreeWidget's header item?



jwieland
28th October 2009, 18:28
Hi,

I was wondering if someone could point out why I can't set background color of a QTreeWidget's header item? I was able to set the foreground of it but cannot change the background color. Here is what I do:

myTree->setHeaderLabels(QStringList() << "blah" << "blah" << "blah";

QTreeWidgetItem *header = myTree->headerItem();
header->setForeground(1, QBrush(Qt::red)); // <<== this works!
header->setBackground(1, QBrush(Qt::green)); // <<== this does not work!

Any help is greatly appreciate.

jwieland
30th October 2009, 12:15
Hello,

Anybody?

cedric.du
4th November 2016, 09:12
Hello from the future

It took me and 3 other guys 48 hours to figure this out and luckily one of us found it.
Here it is:

QHeaderView::section {
background-color: rgb(28, 28, 28);
color: rgb(215, 215, 215);
}

Sorry for taking so long, I hope you found a workaround in the meantime.

Cheers
Cedric