<!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, &nbsp;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>&nbsp;</DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN 
class=788374819-03042005></SPAN></FONT>&nbsp;</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&#8217;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>&nbsp;def cellColor(self, row, col):</FONT> <BR><FONT 
face=Arial size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 
self._cellColor.get((row,col), Qt.white)</FONT> </P>
<P><FONT face=Arial size=2>&nbsp;def paintCell(self, p, row, col, cr, selected, 
cg = None):</FONT> <BR><FONT face=Arial 
size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if cg:</FONT> <BR><FONT 
face=Arial 
size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; myc = 
QColorGroup(cg)</FONT> <BR><FONT face=Arial 
size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
myc.setColor(QColorGroup.Base, self.cellColor(row, col))</FONT> <BR><FONT 
face=Arial 
size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
QTable.paintCell(self, p, row, col, cr, selected, myc) </FONT><BR><FONT 
face=Arial size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else:</FONT> 
<BR><FONT face=Arial 
size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
QTable.paintCell(self, p, row, col, cr, selected)</FONT> </P>
<P><FONT face=Arial size=2>&nbsp;def beginEdit(self, row, col, replace):&nbsp; 
</FONT><BR><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
self.setCellColor( row, col, Qt.red)</FONT> <BR><FONT face=Arial 
size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.repaint()</FONT> 
<BR><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
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&nbsp; 
20132</FONT> </P></BODY></HTML>