[PyQt] SIP - Managing ownership of objects in a QList

Matthias Kuhn matthias.kuhn at gmx.ch
Fri Jun 28 07:51:58 BST 2013


Hi Michael,

That's pretty much what is done in QgsAttributes (see qgsfeature.sip in 
the current master branch)

Regards,
Matthias

On Fre 28 Jun 2013 04:07:59 CEST, michael h wrote:
> I am attempting to figure out the best way make SIP transfer ownership
> of items inside a QList to python.
>
> By default, the generated code for the method which returns the QList
> contains this call:
>
> sipConvertFromNewType(sipRes,sipType_QList_0101SomeType,NULL);
>
> Is there a way to specify the transferObj as "Py_None" so we end up
> with this instead:
>
> sipConvertFromNewType(sipRes,sipType_QList_0101SomeType,Py_None);
>
> This would cause Py_None to be passed to sipConvertToType (in the
> generated converter function) as the transferObj argument and would
> transfer ownership of each item in the QList to python as I need.
>
> Of course if there's another preferred way to get this result, I'm
> glad to be pointed in the right direction.
>
> Michael
>
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt




More information about the PyQt mailing list