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?
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?