I have created subclassed QItemDelegate and redefined the paint method. I have tried
painter.setPen(QtGui.QColor('#FFFFFF'))
which doesnt work. How do I change the text color?
As a side note I tried to color the background by calling painter.setBackground(color) which also doesnt work. How are these methods intended to be used?
class ItemDelegate(QtWidgets.QItemDelegate):
def __init__(self, parent):
QtWidgets.QItemDelegate.__init__(self, parent)
self.parent = parent
def paint(self, painter, option, index):
item = index.data(QtCore.Qt.DisplayRole)
#print(item)
print(dir(painter))
if index.column() == 1:
color = QtGui.QColor('#34ebc6')
elif index.column() == 2:
color = QtGui.QColor('#FFFFFF')
elif index.column() == 3:
color = QtGui.QColor('#9546c7')
else:
color = QtGui.QColor('#FFFFFF')
painter.fillRect(option.rect, color)
super(ItemDelegate, self).paint(painter, option, index)