[PyKDE] How do I delete a QCanvasItem?

Phil Thompson phil at river-bank.demon.co.uk
Tue Jun 11 11:35:01 BST 2002


Moray Taylor wrote:

> I think I have figured out how to do it.
> 
> MyCanvasItem.setCanvas(None)
> 
> It gets rid of it, and seems to free any memory it was using.
> 
> Any comments?


Yes - I'd forgotten I'd already taken care of this. If you look at the 
implementation of QCanvasItem.setCanvas() in qcanvas.sip, ownership is 
transferred to C++ if the item is now allocated to a canvas and 
transferred back to Python if it is not now allocated to a canvas.

Obviously, once ownership is back with Python the C++ dtor will get 
called when the Python object is garbage collected.

Phil




More information about the PyQt mailing list