Adding a class to Qt for Python

From Qt Wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Some C++ Qt classes are not yet exposed in Qt for Python. This page describes how to add one, or even add a class of your own.

Overall the process should consist on:

  • Add the new class into the module's type system e.g.: pyside-setup/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml
  • Add a couple of test cases: e.g.: pyside-setup/sources/pyside2/tests/QtCore/ (don't forget to include the name of the scripts in the cmake file in the same directory)

If you are lucky, the new class will require no extra steps, but probably it will, so for this we recommend that you look at a similar class so you can get an idea of how to solve the issues you find. These issues could include:

  • Ownership transfer
  • Casting argument to different types
  • Explicitly declare enums
  • Adapt method signatures
  • Include new signatures for a certain method

Join us on irc://irc.freenode.net/#qt-pyside if you have any further questions.

See also: