PySide

Introduction
PySide is a Python binding of the cross-platform graphical user interface (GUI) toolkit Qt. FreeCAD uses PySide for all GUI purposes inside of Python.

In the past, FreeCAD used PyQt as its binding, but in 2013 (1dc122dc9a) the project eventually migrated to PySide because it has a more permissible licence. See Differences Between PySide and PyQt for more information on these two bindings.



PySide in FreeCAD with Qt5
FreeCAD was developed to be used with Python 2 and Qt4. As these two libraries became obsolete, FreeCAD transitioned to Python 3 and Qt5. In most cases this transition was done without needing to break backwards compatibility.

Normally, the module provides support for Qt4, while  provides support for Qt5. However, in FreeCAD, there is no need to use directly, as a special  module is included to handle Qt5.

This module is located in the  directory of an installation of FreeCAD compiled for Qt5.

This module just imports the necessary classes from, but places them in the namespace. This means that in most cases the same code can be used with both Qt4 and Qt5, as long as it imports.

The only unusual aspect is that the classes are placed in the  namespace.

Real examples of PySide use

 * PySide Beginner Examples, hello world, announcements, enter text, enter number.
 * PySide Intermediate Examples, window sizing, hiding widgets, popup menus, mouse position, mouse events.
 * PySide Advanced Examples, many widgets.

The examples of PySide are divided into 3 parts, differentiated by level of exposure to PySide, Python and the FreeCAD internals. The first page has an overview on PySide; the second and third pages are mostly code examples at different levels.

It is expected that these examples are useful to get started, and afterwards the user can consult other resources online, or the official documentation.

Documentation
There are some differences in handling of widgets in Qt4 (PySide) and Qt5 (PySide2). The programmer should be aware of these incompatibilities, and should consult the official documentation if something doesn't seem to work as expected in a given platform. Nevertheless, Qt4 is considered obsolete, so most development should target Qt5 and Python 3.

The PySide documentation refers to the Python-style classes; however, since Qt is originally a C++ library, the same information should be available in the corresponding C++ reference.
 * Qt Modules available from PySide2 (Qt5).
 * All Qt classes by module in Qt5 for C++.
 * Qt Modules available from PySide (Qt4).