[PyKDE] Qtable Cell Painting Redux

Matthew Singer matt at finaldraftbooks.com
Sun Apr 3 01:21:19 BST 2005

I'm trying to change the background color of a Qtable cell when the user
starts to edit it (and leave it colored to mark as a changed field.
The code below doesn’t change the color until another cell if clicked. I've
tried everything (except of course what works).
Anyone see what I'm doing wrong?


 def cellColor(self, row, col):
        return self._cellColor.get((row,col), Qt.white)

 def paintCell(self, p, row, col, cr, selected, cg = None):
        if cg:
            myc = QColorGroup(cg)
            myc.setColor(QColorGroup.Base, self.cellColor(row, col))
            QTable.paintCell(self, p, row, col, cr, selected, myc) 
            QTable.paintCell(self, p, row, col, cr, selected)

 def beginEdit(self, row, col, replace):  
        self.setCellColor( row, col, Qt.red)
        QTable.beginEdit(self, row, col, replace)

Matthew Singer
Final Draft Booksellers
Purcellville, VA  20132

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20050403/507154ca/attachment.html

More information about the PyQt mailing list