Python qt: bindings

From wikinotes

Qt is written in C++. bindings make it possible to abstract/expose C++ objects as native python objects.

bindings

Different bindings may be licensed differently, and because of differences in their abstractions - they may not behave consistently. It would be prudent to test against multiple sets bindings, I have personally experienced breaking changes between different bindings to the same version of Qt.

bindings Qt version license project stuatus
PySide Qt4 LGPL completed, no longer receiving fixes
PyQt4 Qt4
PySide2 Qt5 LGPL alpha
PyQt5 Qt5

PySide2

Compiling PySide2: https://fredrikaverpil.github.io/2016/08/17/compiling-pyside2/

abstractions

There are also a handful of libraries that abstract over the various python bindings for qt. These are especially useful if you find yourself needing to support multiple versions of Qt with the same codebase.

project PySide PySide2 PyQt4 PyQt5
Qt.py yes yes yes yes
qtpy yes waiting until beta yes yes

Qt.py

environment variable examples description
QT_PREFERRED_BINDING PySide, PySide2, PyQt4, PyQt5 if defined, use this binding.
import Qt
from Qt import QtWidgets

qtpy

environment variable examples description
QT_API pyside, pyqt4, pyqt5 if defined, use this binding.
from qtpy import QtWidgets