Hi,

I have a C++ class "Project", which I expose to Python
via sip.
In Python, I sub-class:

class Derived(Project):
      ...

In addition, there is a Python factory function which creates an
instance of "Derived" and returns it:

def f():
    return Derived(...)

I call this function from withing C++, and feed the return
value into "sipConvertToType", in order to create a wrapper
of type "Project", so I can call methods of the returned
"Derived" instance from within C++, using the wrapper.

Since the "Derived" instance is created by Python, it is
owned by Python.
Is there a way to transfer ownership to C++ without using any
additional objects? I want the Python part to stick to the
C++ wrapper until the latter is destroyed, at which point
the Python part should also be automatically disposed, without
any need to micro-manage the Python part myself.

In the sip sources, I can see a flag "SIP_CPP_HAS_REF" that
might just achieve that, but there appears to be no official
way to use it.

Best Regards,
Mathias Born


_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to