Fw: [PyKDE] Destructor trouble (how to get rid of child widgets ?)
Thomas Malik
Thomas.Malik at t-online.de
Tue May 23 21:57:47 BST 2000
> So, what to do about it? I can't think of a way to make this transparent
> to the programmer. All I can think of at the moment is to implement
> /TransferBack/ (ie. transfer ownership back to Python) and add it to
> QObject.removeChild(). The following code should then work...
>
> self.removeChild(self.box)
> del self.box
>
he he, so just why was i thinking about the very same possibility ...? That
would help a lot.
I did a 'workaround' by adding a 'widgetStack' accessor function to the
QTabDialog class. Having this, i can at least do a 'removeWidget' call on
the QWidgetStack, getting rid of the 'Properties' page. However, it still
lurks in memory, and that solution does not work for the case where i use a
simple QDialog, where the Properties page sits in.
Maybe adding extra functionality to removeChild is the right thing, it could
decrease the refcnt and completely delete the child if the refcnt drops to 0
(so you won't get a memory leak).
So, how exactly do the QObject & PyObjects in your library relate ? Are your
Python objects just wrappers around the C++ object pointers, or how else is
it set up ? I understand that by 'ownership Transfer' you mean memory
management responsibility, but i don't see how you tell Python about when Qt
deletes an object.
Thomas
More information about the PyQt
mailing list