I want my QTreeWidget to have the same text highlighting when it is inactive as when it is active. So I did:

Qt Code:
  1. QPalette p = palette();
  2. p.setColor(QPalette::Inactive, QPalette::Highlight, p.color(QPalette::Active, QPalette::Highlight));
  3. p.setColor(QPalette::Inactive, QPalette::HighlightedText, p.color(QPalette::Active, QPalette::HighlightedText));
  4. setPalette(p);
To copy to clipboard, switch view to plain text mode 

It did nothing. So I tried:
Qt Code:
  1. QPalette p = palette();
  2. for (int colorRole=0; colorRole < QPalette::NColorRoles; colorRole++)
  3. {
  4. QPalette::ColorRole role = static_cast<QPalette::ColorRole>(colorRole);
  5. p.setColor(QPalette::Inactive, role, p.color(QPalette::Active, role));
  6. }
  7. setPalette(p);
To copy to clipboard, switch view to plain text mode 

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?