[PyQt] sip_api_convert_to_void_ptr returns NULL

Phil Thompson phil at riverbankcomputing.com
Sun Feb 7 16:23:08 GMT 2016


On 7 Feb 2016, at 1:06 am, Tom Brown <nextstate at gmail.com> wrote:
> 
> Hello!
> 
> I have created a PyQt4 application on Windows 10 using Visual Studio 2015.
> 
> In short, I have compiled SIP 4.17 into a static library so that I can use the api "sip_api_convert_to_void_ptr()". This api returns NULL when passed a PyObject * containing a QRect.
> 
> Although, I am using PyQt4 binaries from Anaconda2-2.4.1.
> 
> I have created a Python extension module built with VS 2015. I am passing a QRect to a function in the extension.
> 
> In the function, I am trying to do this:
> 
> PyObject *rect;
> 
> /* call python api to convert args to rect */
> 
> void *ptr = sip_api_convert_to_void_ptr( rect );
> 
> rect = (QRect *)ptr;
> 
> 
> The debugger always shows that ptr is NULL. Even though rect is a valid QRect wrapped by PyQt.
> 
> Any ideas on where I am going wrong here?

From the documentation...

obj – the Python object which may be Py_None, a sip.voidptr or a PyCObject

If you want the address of a wrapped object use sipGetAddress().

Phil


More information about the PyQt mailing list