<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Qtable Cell Painting Redux</TITLE>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.2604" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=788374819-03042005>Ah... when you edit a cell, it creates a lineEdit
widget which you then have to set the background on...</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=788374819-03042005></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=788374819-03042005></SPAN></FONT> </DIV><FONT face=Arial
color=#0000ff size=2></FONT><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> pykde-bounces@mats.imk.fraunhofer.de
[mailto:pykde-bounces@mats.imk.fraunhofer.de] <B>On Behalf Of </B>Matthew
Singer<BR><B>Sent:</B> Saturday, April 02, 2005 7:21 PM<BR><B>To:</B>
pykde@mats.imk.fraunhofer.de<BR><B>Subject:</B> [PyKDE] Qtable Cell Painting
Redux<BR></FONT><BR></DIV>
<DIV></DIV><!-- Converted from text/rtf format -->
<P><FONT face=Arial size=2>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.</FONT></P>
<P><FONT face=Arial size=2>The code below doesn’t change the color until another
cell if clicked. I've tried everything (except of course what works).</FONT></P>
<P><FONT face=Arial size=2>Anyone see what I'm doing wrong?</FONT> </P>
<P><FONT face=Arial size=2>Thanks</FONT> </P><BR>
<P><FONT face=Arial size=2> def cellColor(self, row, col):</FONT> <BR><FONT
face=Arial size=2> return
self._cellColor.get((row,col), Qt.white)</FONT> </P>
<P><FONT face=Arial size=2> def paintCell(self, p, row, col, cr, selected,
cg = None):</FONT> <BR><FONT face=Arial
size=2> if cg:</FONT> <BR><FONT
face=Arial
size=2> myc =
QColorGroup(cg)</FONT> <BR><FONT face=Arial
size=2>
myc.setColor(QColorGroup.Base, self.cellColor(row, col))</FONT> <BR><FONT
face=Arial
size=2>
QTable.paintCell(self, p, row, col, cr, selected, myc) </FONT><BR><FONT
face=Arial size=2> else:</FONT>
<BR><FONT face=Arial
size=2>
QTable.paintCell(self, p, row, col, cr, selected)</FONT> </P>
<P><FONT face=Arial size=2> def beginEdit(self, row, col, replace):
</FONT><BR><FONT face=Arial size=2>
self.setCellColor( row, col, Qt.red)</FONT> <BR><FONT face=Arial
size=2> self.repaint()</FONT>
<BR><FONT face=Arial size=2>
QTable.beginEdit(self, row, col, replace)</FONT> </P><BR><BR>
<P><FONT face=Arial size=2>---------------------------------</FONT> <BR><FONT
face=Arial size=2>Matthew Singer</FONT> <BR><FONT face=Arial size=2>Final Draft
Booksellers</FONT> <BR><FONT face=Arial size=2>Purcellville, VA
20132</FONT> </P></BODY></HTML>