Accepted C++ / Qt constructs

The following constructs can be handled by sip: typedef, struct, class, public, protected, private, signals, slots, virtual, const, static, void, bool, char, short, unsigned, int, long, float, double and enum. There are some restrictions:

class

  • Class definition can not be nested.
  • A class must not have private abstract functions.
  • Constructor must be in the public, private or protected sections.
  • Function must be in the public, private, protected, slot or signal sections.
  • Class variables must be in the public section.
  • Class enums must be in the public or protected sections.

Member functions

Static functions must be public and cannot be virtual.

The syntax of class method declarations is as follows:

name ([arg]..) [const] [=0] [/optflag[,optflag]../] ; [member_code]

Option flags can be given in a comma separated list of optflags enclosed in slashes. optflags can be boolean, or take a value. The following flags are recognized:

Table C-4. Flags in member function declaration

PyName=py_nameUse py_name instead of the C++ function name
ReleaseLockRelease the python interpreter lock
PreHook=hook_functionDefine hook_function to be called prior to the memberfunc
PostHook=hook_functionDefine hook_function to be called after the memberfunc
TransferOwnership is transferred
TransferThisOwnership of this is transferred
TransferBackOwnership is transferred back
protected

If the function is protected, call the public wrapper. Otherwise, explicitly call the real function and not any version in the wrapper class (in case it is virtual). This will prevent virtual loops. You don't need to worry about indirected objects for protected functions.

signals

  • Arguments must be simple. Otherwise you have to supply your own C++ code.
  • Virtual signals are not supported.
slots

  • Arguments must be simple. Otherwise you have to supply your own C++ code.
virtual

  • Static functions cannot be virtual.
  • Virtual signals aren't supported.
  • Arguments must be simple. Otherwise you have to supply your own C++ code.
const

  • Accepted for const function arguments and const functions.
static

  • %VariableCode cannot be specified for non-static class variables.
  • Cannot mix static and non-static member functions with the same Python name.
  • Static functions must be public and cannot be virtual.