<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7036.0">
<TITLE>Qtable Cell Painting Redux</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<P><FONT SIZE=2 FACE="Arial">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 SIZE=2 FACE="Arial">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 SIZE=2 FACE="Arial">Anyone see what I'm doing wrong?</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">Thanks</FONT>
</P>
<BR>
<P><FONT SIZE=2 FACE="Arial"> def cellColor(self, row, col):</FONT>
<BR><FONT SIZE=2 FACE="Arial"> return self._cellColor.get((row,col), Qt.white)</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial"> def paintCell(self, p, row, col, cr, selected, cg = None):</FONT>
<BR><FONT SIZE=2 FACE="Arial"> if cg:</FONT>
<BR><FONT SIZE=2 FACE="Arial"> myc = QColorGroup(cg)</FONT>
<BR><FONT SIZE=2 FACE="Arial"> myc.setColor(QColorGroup.Base, self.cellColor(row, col))</FONT>
<BR><FONT SIZE=2 FACE="Arial"> QTable.paintCell(self, p, row, col, cr, selected, myc) </FONT>
<BR><FONT SIZE=2 FACE="Arial"> else:</FONT>
<BR><FONT SIZE=2 FACE="Arial"> QTable.paintCell(self, p, row, col, cr, selected)</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial"> def beginEdit(self, row, col, replace): </FONT>
<BR><FONT SIZE=2 FACE="Arial"> self.setCellColor( row, col, Qt.red)</FONT>
<BR><FONT SIZE=2 FACE="Arial"> self.repaint()</FONT>
<BR><FONT SIZE=2 FACE="Arial"> QTable.beginEdit(self, row, col, replace)</FONT>
</P>
<BR>
<BR>
<P><FONT SIZE=2 FACE="Arial">---------------------------------</FONT>
<BR><FONT SIZE=2 FACE="Arial">Matthew Singer</FONT>
<BR><FONT SIZE=2 FACE="Arial">Final Draft Booksellers</FONT>
<BR><FONT SIZE=2 FACE="Arial">Purcellville, VA 20132</FONT>
</P>
</BODY>
</HTML>