[PyQt] SIP and void* handling

Phil Thompson phil at riverbankcomputing.com
Mon Jul 4 08:37:17 BST 2016


On 4 Jul 2016, at 3:59 am, Scott Talbert <swt at techie.net> wrote:
> 
> Hi,
> 
> I have a wrapped C++ class with a function that returns a void*.
> 
> Also, I have a Python class that inherits from the wrapped C++ class and overrides the function that returns a void*.
> 
> Lastly, I have C++ code that ends up calling the Python subclass's void* function.  When this happens, however, I'm getting this error:
> 
> TypeError: invalid result from MyDataTable.GetValueAsCustom(), an integer is required
> 
> This appears to be because the Python class (MyDataTable) is getting returned as the void*, not a sip.voidptr.  How do I get a sip.voidptr to be returned?
> 
> One additional caveat, the C++ code expects to delete the void* object, so it needs to take ownership of it as well.

The best bet is probably to work around the broken C++ API by doing so conversions in the .sip files and present a more sensible API - so instead of a void* a MyDataTable (or super-class) instance is returned.

Phil


More information about the PyQt mailing list