PyQt

Last updated
PyQt
Developer(s) Riverbank Computing
Initial release1998
Stable release
6.9.1 [1]   OOjs UI icon edit-ltr-progressive.svg / 6 June 2025;23 days ago (6 June 2025)
Written in C++ / Python [2]
Operating system Cross-platform
License GNU GPL and commercial
Website riverbankcomputing.com

PyQt is a Python binding of the cross-platform GUI toolkit Qt, implemented as a Python plug-in. PyQt is free software developed by the British firm Riverbank Computing. It is available under similar terms to Qt versions older than 4.5; this means a variety of licenses including GNU General Public License (GPL) and commercial license, but not the GNU Lesser General Public License (LGPL). [3] PyQt supports Microsoft Windows as well as various kinds of UNIX, including Linux and macOS. [4]

Contents

PyQt implements around 440 classes and over 6,000 functions and methods [5] including:

To automatically generate these bindings, Phil Thompson developed the tool SIP, which is also used in other projects.

History

PyQt was first released by Riverbank Computing in 1998. [8]

In August 2009, Nokia sought for the Python binding to be available under the LGPL license. At the time, Nokia owned Qt Software, the developer of QT. After failing to reach an agreement with Riverbank Computing, Nokia released its binding, PySide, providing similar functionality. [9]

Main components

Alternative PyQt logo Python and Qt 2.svg
Alternative PyQt logo

PyQt4 contains the following Python modules.

PyQt5 contains the following Python modules:

Versions

PyQt version 4 works with both Qt 4 and Qt 5. PyQt version 5 only supports Qt version 5, [4] and drops support for features that are deprecated in Qt 5. [11]

Hello World example

The result in KDE Plasma 4 PyQt screen.png
The result in KDE Plasma 4

The below code written for PyQt6 shows a small window on the screen.

#!/usr/bin/env python3"""Here we provide the necessary imports.The basic GUI widgets are located in QtWidgets module."""importsysfromPyQt6.QtWidgetsimportQApplication,QWidget# Every PyQt application must create an application object.# The application object is located in the QtWidgets module.app=QApplication([])# The QWidget widget is the base class of all user interface objects in PyQt.# We provide the default constructor for QWidget. The default constructor has no parent.# A widget with no parent is called a window.root=QWidget()root.resize(320,240)# The resize() method resizes the widget.root.setWindowTitle("Hello, World!")# Here we set the title for our window.root.show()# The show() method displays the widget on the screen.sys.exit(app.exec())# Finally, we enter the mainloop of the application.

Notable applications that use PyQt

See also

References

  1. https://riverbankcomputing.com/news/PyQt_v6.9.1_Released.{{cite web}}: Missing or empty |title= (help)
  2. "PyQt4 Download". Riverbankcomputing. 2010. Retrieved 2010-04-19.
  3. "Riverbank | Commercial | License FAQ". Riverbankcomputing.com. Retrieved 2015-06-24.
  4. 1 2 "What is PyQt?". Riverbank Computing. Retrieved 2014-09-18.
  5. "PyQt v4 - Python Bindings for Qt v4". Riverbankcomputing. Archived from the original on 2008-04-29. Retrieved 2010-04-17.
  6. "QSqlDatabase Class Reference". Pyqt.sourceforge.net. Retrieved 2014-09-25.
  7. PythonInfo Wiki
  8. Jarmul, Katharine; Lawson, Richard (2017-05-30). Python Web Scraping. Packt Publishing Ltd. p. 105. ISBN   978-1-78646-429-3.
  9. faq, Martin Fitzpatrick Last updated (2019-06-21). "PyQt5 vs PySide2: What's the difference between the two Python Qt libraries?". Python GUIs. Retrieved 2022-06-25.
  10. "Riverbank | Software | PyQt | What is PyQt?". Riverbankcomputing.co.uk. Retrieved 2010-04-15.
  11. "Differences Between PyQt4 and PyQt5", PyQt 5.3.2 Reference Guide, archived from the original on 2018-08-14, retrieved 2014-09-18

Further reading