[PyKDE] Next sip4 Problem, WAS: ANN: SIP v4.0pre3 Released
Hans-Peter Jansen
hpj at urpla.net
Wed Oct 29 17:56:01 GMT 2003
On Wednesday 29 October 2003 14:07, Phil Thompson wrote:
>
> There are two unrelated bugs - fixes will be in tonight's snapshot,
> or apply the attached patch.
Thanks, applied it, and they vanished. Cool.
Now, I have two (related?) problems in a QDataTable derived class:
Traceback (most recent call last):
File "/home/hp/src/python/qt/wiv/artikeltable.py", line 38, in paintField
fn = str(field.name())
AttributeError: name
QWidget (qt_clipped_viewport): deleted while being painted
QPaintDevice: Cannot destroy paint device that is being painted
Traceback (most recent call last):
File "/home/hp/src/python/qt/wiv/artikeltable.py", line 51, in paintField
Qt.AlignRight|Qt.AlignVCenter, v)
RuntimeError: underlying C/C++ object has been deleted
QWidget (qt_clipped_viewport): deleted while being painted
QPaintDevice: Cannot destroy paint device that is being painted
which are triggered unpredictably. Here's the source:
# -*- coding: iso-8859-1 -*-
from qt import *
from qtsql import QDataTable
class ArtikelTable(QDataTable):
def __init__(self, *args):
#print "ArtikelTable.__init__"
apply(QDataTable.__init__, (self,) + args)
self.addColumn("artnr", "ArtNr")
self.addColumn("bez", "Bezeichnung")
self.addColumn("firma", "Firma")
self.addColumn("sorte", "Sorte")
self.addColumn("gewicht", "Gewicht")
self.addColumn("faktor", "Faktor")
self.addColumn("bem", "Bemerkungen")
self.addColumn("created", "Erfasst")
self.addColumn("changed", "Geändert")
self.addColumn("changedby", "von")
self.setReadOnly(1)
self.setSorting(1)
self.setAutoEdit(0)
ArtikelTable_stringlist = QStringList()
ArtikelTable_stringlist.append("artnr ASC")
self.setSort(ArtikelTable_stringlist)
def keyPressEvent(self, e):
k = e.key()
if k == Qt.Key_Return or k == Qt.Key_Enter:
self.emit(PYSIGNAL("EditArtikel"), ())
e.accept()
else:
QDataTable.keyPressEvent(self, e)
def paintField(self, p, field, cr, b):
if not field:
return
fn = str(field.name()) # <<< Line 38
if fn in ("gewicht", "faktor"):
cur = self.sqlCursor()
gew = cur.field("gewicht").value().toDouble()
fak = cur.field("faktor").value().toDouble()
if fak == 0.0 or gew > (fak * 1.8):
p.setPen(QColor("red"))
v = QString("%.2f" % field.value().toDouble())
p.drawText(2, 2, cr.width()-8, cr.height()-4,
Qt.AlignRight|Qt.AlignVCenter, v)
elif fn in ("artnr", "firma", "sorte"):
v = field.value().toString()
p.drawText(2, 2, cr.width()-8, cr.height()-4,
Qt.AlignRight|Qt.AlignVCenter, v) # <<< Line 51
else:
QDataTable.paintField(self, p, field, cr, b)
Cheers,
Pete
More information about the PyQt
mailing list