[PyKDE] Re: How do I fix this?

Phil Thompson phil at river-bank.demon.co.uk
Sat Feb 16 11:21:12 GMT 2002


ian reinhart geiser wrote:
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Greetings
> I have a situation where I am wrapping a class that handles its instances
> internally  Basicly when i create a new object as follows:
>         myObject(parent, name)
> 
> The parent manages the instance and the instance is kept in the parents
> internal lookup table.  The problem is at the end of the function python
> cleans the myObject instance up.  Is there a way to keep python from killing
> these objects, but still allow me to delete them from C++?

Use the /TransferThis/ option on the parent argument. Look at the .sip
file for any PyQt class that is derived from QObject.

The result is that the generated code transfers ownership (ie.
responsibility for calling the dtor) for the new instance to the parent
object (so long as the parent object is non-zero).

Phil




More information about the PyQt mailing list