[PyKDE] How do I delete a QCanvasItem?
boud at valdyas.org
Mon Jun 10 22:41:00 BST 2002
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
from qt import *
from qtcanvas import *
def __init__(self, *args):
self.canvas = QCanvas(100,100)
QCanvasView.__init__(self, self.canvas, *args)
item = QCanvasText("bla", self.canvas)
if __name__ == '__main__':
app = QApplication(sys.argv)
win = cv()
print win.canvas.allItems() # __init__ has run, so item should be
Boudewijn Rempt | http://www.valdyas.org
More information about the PyQt