PDA

View Full Version : Changing the inactive palette to an active palette in a QTreeWidget doesn't work?



gemmell
21st March 2013, 11:10
I want my QTreeWidget to have the same text highlighting when it is inactive as when it is active. So I did:



QPalette p = palette();
p.setColor(QPalette::Inactive, QPalette::Highlight, p.color(QPalette::Active, QPalette::Highlight));
p.setColor(QPalette::Inactive, QPalette::HighlightedText, p.color(QPalette::Active, QPalette::HighlightedText));
setPalette(p);

It did nothing. So I tried:


QPalette p = palette();
for (int colorRole=0; colorRole < QPalette::NColorRoles; colorRole++)
{
QPalette::ColorRole role = static_cast<QPalette::ColorRole>(colorRole);
p.setColor(QPalette::Inactive, role, p.color(QPalette::Active, role));
}
setPalette(p);


It also didn't work. I have also tried setting the palette on the viewport and had a quick look to see whether I'm supposed to set it on the delegate (but the delegate doesn't have a palette). This seemingly 5 minute task is now chewing up hours. Does anybody know what I have to do make it so that my inactive and active highlights on a QTreeWidget are the same?

alena
19th March 2014, 23:25
Have you tryed setting up the stylesheet on the QTreeWidget?? Something like:

QTreeWidget::item:active {background-color: rgb(30, 30, 30);
selection-background-color: rgb(30, 30, 30);}

QTreeWidget::item:inactive {background-color: rgb(30, 30, 30);
selection-background-color: rgb(30, 30, 30);}

or eve setting the selection-background-color to any color with alpha 0 (ex rgba(30, 30, 30,0))?