[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: RE: [PyKDE] Qtable Cell Painting Redux
From: "Matthew Singer" <matt () finaldraftbooks ! com>
Date: 2005-04-03 19:49:37
Message-ID: 464JDcTxp0084M38 () cmsapps02 ! cms ! usa ! net
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Ah... when you edit a cell, it creates a lineEdit widget which you then
have to set the background on...
_____
From: pykde-bounces@mats.imk.fraunhofer.de
[mailto:pykde-bounces@mats.imk.fraunhofer.de] On Behalf Of Matthew Singer
Sent: Saturday, April 02, 2005 7:21 PM
To: pykde@mats.imk.fraunhofer.de
Subject: [PyKDE] Qtable Cell Painting Redux
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?
Thanks
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)
else:
QTable.paintCell(self, p, row, col, cr, selected)
def beginEdit(self, row, col, replace):
self.setCellColor( row, col, Qt.red)
self.repaint()
QTable.beginEdit(self, row, col, replace)
---------------------------------
Matthew Singer
Final Draft Booksellers
Purcellville, VA 20132
[Attachment #5 (text/html)]
<!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>
_______________________________________________
PyKDE mailing list PyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic