Adding a class to Qt for Python
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.
- Alexandru's blog post: Write your own Python bindings