Introduction

This is the reference guide for PyQt5 5.9. PyQt5 is a set of Python bindings for v5 of the Qt application framework from The Qt Company.

Qt is a set of C++ libraries and development tools that includes platform independent abstractions for graphical user interfaces, networking, threads, regular expressions, SQL databases, SVG, OpenGL, XML, user and application settings, positioning and location services, short range communications (NFC and Bluetooth) and access to the cloud. PyQt5 implements over 1000 of these classes as a set of Python modules.

PyQt5 supports the Windows, Linux, UNIX, Android, OS X and iOS platforms.

PyQt does not include a copy of Qt. You must obtain a correctly licensed copy of Qt yourself. However, binary wheels of the GPL version of PyQt5 are provided and these include a copy of the appropriate parts of the LGPL version of Qt.

The homepage for PyQt5 is https://www.riverbankcomputing.com/software/pyqt/. Here you will always find the latest stable version, current development previews, and the latest version of this documentation.

PyQt5 is built using the SIP bindings generator. SIP must be installed in order to build and use PyQt5.

Earlier versions of Qt are supported by PyQt4.

License

PyQt5 is dual licensed on all platforms under the Riverbank Commercial License and the GPL v3. Your PyQt5 license must be compatible with your Qt license. If you use the GPL version then your own code must also use a compatible license.

PyQt5, unlike Qt, is not available under the LGPL.

You can purchase a commercial PyQt5 license here.

PyQt5 Components

PyQt5 comprises a number of different components. First of all there are a number of Python extension modules. These are all installed in the PyQt5 Python package and are described in the list of modules.

PyQt5 contains plugins that enable Qt Designer and qmlscene to be extended using Python code. See Writing Qt Designer Plugins and Integrating Python and QML respectively for the details.

PyQt5 also contains a number of utility programs.

  • pyuic5 corresponds to the Qt uic utility. It converts QtWidgets based GUIs created using Qt Designer to Python code.
  • pyrcc5 corresponds to the Qt rcc utility. It embeds arbitrary resources (eg. icons, images, translation files) described by a resource collection file in a Python module.
  • pylupdate5 corresponds to the Qt lupdate utility. It extracts all of the translatable strings from Python code and creates or updates .ts translation files. These are then used by Qt Linguist to manage the translation of those strings.

The DBus support module is installed as dbus.mainloop.pyqt5. This module provides support for the Qt event loop in the same way that the dbus.mainloop.glib included with the standard dbus-python bindings package provides support for the GLib event loop. The API is described in DBus Support. It is only available if the dbus-python v0.80 (or later) bindings package is installed. The QtDBus module provides a more Qt-like interface to DBus.

When PyQt5 is configured a file called PyQt5.api is generated. This can be used by the QScintilla editor component to enable the use of auto-completion and call tips when editing PyQt5 code. The API file is installed automatically if QScintilla is already installed.

PyQt5 includes a large number of examples. These are ports to Python of many of the C++ examples provided with Qt. They can be found in the examples directory.

Finally, PyQt5 contains the .sip files used by SIP to generate PyQt5 itself. These can be used by developers of bindings of other Qt based class libraries.

An Explanation of Version Numbers

Historically the version number of PyQt bears no relation to the version of Qt supported. It’s no longer even true that PyQt4 requires Qt v4 as it will also build against Qt v5. People sometimes mistakenly believe that, for example, PyQt4 v4.8 is needed when building against Qt v4.8.

When refering to a version number we assume it consists of three numbers separated by a dot. These are the major number, the minor number and the maintenance number. The major number will always be 5. The maintenance number may be omitted if it is 0.

Starting with PyQt5 the version number of PyQt5 is tied, to a certain extent, to the version of Qt v5. This is based on the following assumptions.

  • All parts of the Qt API will be supported throughout the life of Qt v5 even though some may be marked as deprecated or obsolete at some point.
  • When new parts of the Qt API are introduced the minor number of the version will be increased and the maintenance number will be reset to 0.

Therefore, for PyQt5 v5.n.* the following are true.

  • It will build against any version of Qt v5, but will not support any new features introduced in Qt v5.n+1 or later.
  • It will support all the features of supported modules of Qt v5.n or earlier.
  • Support for new modules may be added to PyQt5 at any time. This would result in a change of maintenance number only.

The maintenance numbers of PyQt5 and Qt v5 are entirely unrelated to each other.

So, for example, PyQt5 v5.1 will build against Qt v5.2 but will not support any new features introduced in Qt v5.2. PyQt5 v5.1 will support all the features of supported modules of Qt v5.0 and those new features introduced in Qt v5.1.

In summary, just as with PyQt4, you should always try and use the latest version of PyQt5 no matter what version of Qt v5 you are using.