[PyKDE] QGraphisScene removeItem problem
Remy Anthoine
remy.anthoine at gmail.com
Mon Dec 11 13:20:42 GMT 2006
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)
More information about the PyQt
mailing list