Hi everyone,<br><br>I am struggling to get what seems to be a simple delegate working.<br><br>What I want is to change the background of a tableview cell, from what I understand<br>I should be looking at the Qt.BackgroundRole. So far I havent bee able to get it working.<br>
<br>What I have so far, is a delegate that fills the cell with a color, but it seems to be going<br>on top of the text:<br><br>class CellBackgroundColor(QtGui.QStyledItemDelegate):<br><br> def __init__(self, parent = None):<br>
QtGui.QStyledItemDelegate.__init__(self, parent)<br><br> def paint(self, painter, option, index): <br><br> path = index.model().data(index, QtCore.Qt.DisplayRole).toString()<br> painter.fillRect(option.rect, QtGui.QColor(path))<br>
<br>Any ideas on how to implement this Qt.BackgroundRole in a tableview delegate?<br><br>Thanks in advance,<br>Cris<br>