SIP: using %InstanceCode for pure virtual class

James Jurack James.Jurack at
Fri Aug 6 21:12:50 BST 2021


I am trying to use SIP to wrap a pure virtual class. Since it does not have a callable constructor, it instead has a static factory function that returns an instance of a hidden subclass.

>From the docs, I've gathered that SIP provides %InstanceCode to cover this use case, but it appears it's not doing anything. My class is defined in my .sip file like so:

class MyLib
#include <MyLib.h>
    sipCpp = ::MyLib::Create();

But there is no change in the CPP code that SIP generates, whether I include the %InstanceCode or not; it's still trying to call my class's constructor directly, and I can't find my call to Create() anywhere in the generated code.

Am I misunderstanding how %InstanceCode is supposed to work?

Thanks very much for any help!


James Jurack

Systems Engineer

[cid:fb44a353-f222-4d6f-916f-b787ae52e8fa]                                                                                                 [cid:66a639b5-c3f2-4379-bf03-21abfc8848ff]

5425 Warner Rd. | Suite 13 | Valley View, OH 44125 |<>

P. +1.216.447.8950 x2013 | F: +1.216.447.8951 | james.jurack at<mailto:email at>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Outlook-3s2hj143.jpg
Type: image/jpeg
Size: 1664 bytes
Desc: Outlook-3s2hj143.jpg
URL: <>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Outlook-0w0iz24j.jpg
Type: image/jpeg
Size: 1151 bytes
Desc: Outlook-0w0iz24j.jpg
URL: <>

More information about the PyQt mailing list