[PyKDE] QGraphisScene removeItem problem
Phil Thompson
phil at riverbankcomputing.co.uk
Tue Dec 12 00:50:22 GMT 2006
On Monday 11 December 2006 1:20 pm, Remy Anthoine wrote:
> Greetings,
>
> I'm having trouble using the removeItem operation of a scene in PyQt4
> with python 2.5 under windows XP. Can someone explain why the
> following produces an error of type : "python.exe has encountered a
> problem and needs to close. We are sorry for the inconvenience."
>
> import sys
> from PyQt4 import QtCore, QtGui
>
> class testtotrash(QtGui.QWidget):
> def __init__(self,parent= None):
> QtGui.QWidget.__init__(self, parent)
> scene = QtGui.QGraphicsScene()
>
> scene.addText("TEST")
>
> for i in scene.items():
> scene.removeItem(i)
>
> if __name__ == "__main__":
> app = QtGui.QApplication(sys.argv)
> myTTT = testtotrash()
> myTTT.show()
>
> sys.exit(app.exec_())
>
> I discovered this was a problem in a larger application where I
> sometimes remove all the items of a scene. It worked fine with
> ellipses or pixmaps but not since I started using QGraphicsTextItem.
> In the larger application, I get the following message along with
> windows' "python.exe has encountered..." :
> QGraphicsScene::removeItem: item 017098D8's scene (00000000) is
> different from this scene (016AF2E8)
Fixed in tonight's snapshot. Some handwritten code didn't deal with the fact
that QGraphicsTextItem multiply inherits.
Thanks,
Phil
More information about the PyQt
mailing list