On Monday 10 June 2002 21:29, Stephen Green wrote: > I've been trying to figure out how to delete a QCanvasItem from a QCanvas. > I tried using del, QCanvas.removeChild() and removing all references to it. > None of this works though. I think removeChild() doesn't work because it > takes a QObject as input, but QCanvasItem does not inherit QObject. Does > anybody know how to do this? >
I've just experimented a bit, and I found that canvas items just don't disappear. I think that's a bug. The only sure way of making items disappear currently is to hide() them, and that could lead to prodigious memory leaks. # # canvas.py # import sys from qt import * from qtcanvas import * class cv(QCanvasView): def __init__(self, *args): self.canvas = QCanvas(100,100) QCanvasView.__init__(self, self.canvas, *args) item = QCanvasText("bla", self.canvas) item.move(0,0) item.show() self.canvas.resize(0, 0) self.canvas.update() self.canvas.resize(100, 100) self.canvas.update() if __name__ == '__main__': app = QApplication(sys.argv) QObject.connect(app, SIGNAL('lastWindowClosed()') , app , SLOT('quit()') ) win = cv() print win.canvas.allItems() # __init__ has run, so item should be # dereferenced. app.setMainWidget(win) win.show() app.exec_loop() -- Boudewijn Rempt | http://www.valdyas.org _______________________________________________ PyKDE mailing list [EMAIL PROTECTED] http://mats.gmd.de/mailman/listinfo/pykde