Hi everyone,

I am struggling to get what seems to be a simple delegate working.

What I want is to change the background of a tableview cell, from what I
understand
I should be looking at the Qt.BackgroundRole. So far I havent bee able to
get it working.

What I have so far, is a delegate that fills the cell with a color, but it
seems to be going
on top of the text:

class CellBackgroundColor(QtGui.QStyledItemDelegate):

    def __init__(self, parent = None):
        QtGui.QStyledItemDelegate.__init__(self, parent)

    def paint(self, painter, option, index):

        path = index.model().data(index,  QtCore.Qt.DisplayRole).toString()
        painter.fillRect(option.rect, QtGui.QColor(path))

Any ideas on how to implement this Qt.BackgroundRole in a tableview
delegate?

Thanks in advance,
Cris
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to