Hi! I'm trying to add some pixmap (many pixmap in the same column, a progress bar and probably more stuff in the future) to my TreeView, I found the best way to do it is to set a delegate.
It does works properly, but it looks ugly when I select the row. I fill the background by doing painter.fillRect(option.rect, self.palette.highlight()), but on Windows Vista/7 it does not show the modern "explorer" look like it should, it shows a blue background.

I've search everywhere without any luck.

This is a snippet of my code:

Qt Code:
  1. class ProgressBarDelegate(QStyledItemDelegate):
  2. def __init__(self, parent):
  3. QStyledItemDelegate.__init__(self, parent)
  4. self.palette = parent.palette()
  5.  
  6. def paint(self, painter, option, index):
  7. if not index.isValid():
  8. return None
  9. #painter.save()
  10. #if option.state & QStyle.State_Selected: #paint background if selected.
  11. #painter.fillRect(option.rect, painter.brush())
  12. #painter.fillRect(option.rect, self.palette.highlight())
  13. progress = index.data()
  14. bar_option = QStyleOptionProgressBar()
  15. bar_option.rect = option.rect
  16. bar_option.rect.setHeight(option.rect.height() - 1)
  17. bar_option.rect.setTop(option.rect.top() + 1)
  18. bar_option.minimum = 0
  19. bar_option.maximum = 100
  20. bar_option.progress = int(progress)
  21. bar_option.text = progress + '%'
  22. bar_option.textVisible = True
  23. bar_option.textAlignment = Qt.AlignCenter
  24. QApplication.style().drawControl(QStyle.CE_ProgressBar, bar_option, painter)
  25. #painter.restore()
To copy to clipboard, switch view to plain text mode 

This is the current result:

http://i.stack.imgur.com/TIJK1.jpg

This is what I want:

http://i.stack.imgur.com/7WtQx.jpg


related stackoverflow question > http://stackoverflow.com/questions/7...indows-vista-7