Hello,

Using Qt 4.4.1, Windows

I have a QTreeWidget, with items that can have other colors than standard.

When an item is NOT selected, it works perfectly. When an item is selected, it does not. If the tree does not have the focus, the selected item also does not have the color I want.

This is a sample of the Paint function in my tree item delegate: None of the palette settings (In this sample QPalette:All, but any other setting also gives the result) work.

It doesn't matter if I give the tree item a different color or change text and foreground color of the treeItem: when an item is the current item, it is White (when highlighted) or Black when the tree does not have the focus...

Qt Code:
  1. QColor dirtyColor = Qt::red
  2. QPalette p = pTree->palette();
  3. QPalette old_palette = p;
  4. p.setColor(QPalette::All, QPalette::Text, dirtyColor);
  5. p.setColor(QPalette::All, QPalette::HighlightedText, dirtyColor);
  6. p.setColor(QPalette::All, QPalette::BrightText, dirtyColor);
  7.  
  8. pTree->setPalette(p);
  9.  
  10. pItem->setTextColor(index.column(), dirtyColor);
  11. pItem->setForeground(index.column(), dirtyColor);
  12.  
  13. QItemDelegate::paint(painter, option, index);
  14. pTree->setPalette(old_palette);
To copy to clipboard, switch view to plain text mode 

Does anyone know what to do?