Qt for Python/Shiboken: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
(Created page with "'''Shiboken''' (''Shi bō ken'', 死某剣) is the Python binding generator that Qt for Python uses to create the PySide module, in other words, is the system we use to expose...")
 
No edit summary
Line 17: Line 17:


== Documentation ==
== Documentation ==
* [https://doc.qt.io/qtforpython/shiboken2/contents.html Official documentation]
* [https://doc.qt.io/qtforpython/shiboken2/index.html Official documentation]
* [https://setanta.wordpress.com/2009/08/31/shiboken/ Release blog post (external)]
* [https://setanta.wordpress.com/2009/08/31/shiboken/ Release blog post (external)]



Revision as of 10:46, 29 March 2020

Shiboken (Shi bō ken, 死某剣) is the Python binding generator that Qt for Python uses to create the PySide module, in other words, is the system we use to expose the Qt C++ API to Python.

The name Shiboken2 and PySide2 make reference to the Qt 5 compatibility, since the previous versions (without the 2) refer to Qt 4.

The process

Relation between Qt, Shiboken and PySide

Shiboken uses an ApiExtractor library (based on an old project called QtScriptGenerator) to parse the Qt Headers and get the information of all the Qt classes, using Clang. This step is not Qt-dependent, so it can be use for other C++ projects as well.

Additionally, Shiboken has a Typesystem (based on XML) which allows modifying the obtained information to properly represent and manipulate the C++ classes into the Python World.

Through this Typesystem we can remove and add methods to certain classes, and even modify the arguments of each function, which is really necessary when both C++ and Python collide and a decision needs to be made to properly handle the data structures or types.

The outcome of this process is a set of wrappers written in CPython, which allow us to easily compile and then provide you the python module called PySide2.

Documentation

Example