[PyQt] Getting %If checks to work in SIP class declarations

Phil Thompson phil at riverbankcomputing.com
Sat Aug 2 21:43:19 BST 2014


On 02/08/2014 9:04 pm, Raphael Kubo da Costa wrote:
> PyKDE's bindings are having some trouble with SIP 4.16 after it renamed
> annotations like PyQt4NoQMetaObject to PyQtNoQMetaObject.
> 
> I was trying to check for SIP_4_16 in the sip files and do something
> like this:
> 
>   %If (SIP_4_16 - )
>   class Foo : QObject /NoDefaultCtors,PyQtNoQMetaObject/
>   %End
>   %If ( - SIP_4_16)
>   class Foo : QObject /NoDefaultCtors,PyQt4NoQMetaObject/
>   %End
>   {
>     ...
>   }
> 
> but sip errors out with a syntax error pointing to the line with the
> first %End.
> 
> Is there a different way to do this?

SIP doesn't have a separate pre-processor - %If etc are part of the 
language syntax. You have to have alternate complete class definitions.

Phil


More information about the PyQt mailing list