
While the Qt APIs are world renowned, there are more reasons why you should consider Qt for Python. Qt for Python is the project that provides the official set of Python bindings (PySide6) that will supercharge your Python applications. Design GUI with Python: Python Bindings for Qt. Qt for Python pip install pyside6. Documentation Resource Center Blog Qt World Summit 2021.

Back in the days when Qt was owned by Nokia, Nokia decided to create their own Qt binding PySide. To understand this phenomenon we have to take a look Qt's history.PyQt exists for a long time and is supported by Riverbank Computing Limited, a small (one-person?) consulting firm. Pyqt5 combobox documentation.When reading this article, you will probably be confused about why there are two Python bindings for the Qt GUI framework and not only one. PyQt5 radiobutton QRadioButton. PyQt QComboBox - working with QComboBox widget in PyQt.
At the end of 2018, the first version of Qt for Python, the new name for PySide2, was released. In 2016, the project was internally picked up by the Qt Company.In 2018, support for PySide2 was officially announced up by the Qt Company, the official company behind Qt. Since then, PySide was solely supported by the open source community and for the most part, lacked behind PyQt.Christian Tismer picked up the work on Qt5 support in PySide2 in 2015 for AutoDesk and created a first merely usable version.
However, in some cases, for example, when you want to build an open-source application that can be used in closed-source commercial projects, it may be significant that the dependency libraries don't use the GPL.When you are working on a commercial application, however, it does matter if you select the GPL, LGPL or any of the commercial licenses. The price for a commercial Qt license varies depending on the size of your company and your application.What does this mean for your application? If you are developing open-source software, for the most part, it doesn't matter. Qt for Python is available under the LGPL v3 and the Qt Commercial License.The PyQt5 commercial license costs 550$ net with one year support. PyQt5 is released under the GNU GPL v3 and the Riverbank Commercial License. The Qt for Python API is even designed to be compatible with PyQt5.Moreover, I'm going to explain the difference in the following areas in detail.The most significant difference between PyQt5 and PySide2 is the license.
Pyqt5 Documentation How To Replace The
So in case you intend to lock down your application, you may need to buy a commercial license for Qt additionally.Therefore, in my opinion, Qt for Python strongly wins when it comes to licensing. This especially important for embedded devices, when you intend to lock down the users' access to the file system.However, be aware that the Riverbank Commercial License is only applicable to the Python binding and not Qt itself. For most commercial applications this is unacceptable.The LGPL however, allows you to distribute your closed-source application along with instructions on how to replace the library.The commercial license allows you to distribute your application without requiring any instructions.
However, the difference might be insignificant if you use the Python binding to work with Qt Quick. Most of the libraries seem to be focused on the use with Qt widgets.PySide2 currently has no dedicated deployment tool.PyQt wins when it comes to tools. However, I couldn't get it to work correctly for Android, due to lack of sufficient documentation.Moreover, PyQt comes with additional add-ons and libraries including QScintilla2 and dip. One of the most interesting ones is the pyqtdeploy tool, which claims to be able to deploy PyQt applications for Windows, Linux, OS X, Android and, even iOS.I have tested the tool, and it seems to work for desktop platforms.
Community and SupportAn important factor when choosing an open source project or any dependency library over another is the community and support behind the project.Here PyQt and Qt for Python significantly differ. For example, I recently discovered that QValidator implementations in Python registered to QML don't work.Overall, I would say PyQt5 wins this battle compared to PySide2. However, from my experience, I know that both bindings have their flaws.Qt for Python is still relatively new, and therefore, some essential API functions, including for example qmlRegisterSingletonType are still missing.From my experience with PyQt5, I also know that QML related features might be missing or untested.
Binding GeneratorWhich Python C/C++ binding generator the binding uses might not be relevant to you if you want to use the library without adding any additional C++ libs. We hope that it will not happen, but if he/she gets hit by a bus, you are out of luck.Qt for Python clearly wins this point. The Qt Company, on the other hand, can provide support for all types of customers, including project-based consulting and on-site support.Also important to notice is the fact that the supporting company behind PyQt, Riverbank Computing, is a tiny company, probably only one person. However, which quality of support is given, is unclear. The development process is open and very close to the development process of Qt.Commercial support for PyQt is cheaper than the commercial support for Qt for Python. However, the development process doesn't seem to be very open, and it is lead by a single entity.PySide has lost most of the community from the Nokia days, but since it has been picked up as official Qt binding for Python, it's very likely that the community will quickly catch up.
Most importantly, every function which should be exposed needs to be defined.The Shiboken code, on the other hand, looks as follows: #ifndef BINDINGS_HWe have a bindings header file and an XML file specifying a type system. // Define the interface to the word library.The SIP specification looks as follows: // Define the SIP wrapper to the word library.As you can see, the SIP specification code is mostly copy-and-paste of the actual C++ code. Let's take a look at a short example. Shiboken, on the other hand, is designed to work with C++.How to create custom bindings with SIP and Shiboken strongly differs.
This important for projects such as RViz which provide Python bindings for PyQt and PySide. Python_qt_bindings additionally provides a small CMAKE shim for Shibokem and SIP. A couple of projects already take advantage of this fact and provide a small abstraction layer over both libraries.The most popular one is probably QtPy, I use python_qt_binding, the wrapper used in ROS, in most of my projects. As of the beginning of 2019, the choice between PySide2 and PyQt is not easy to decide.Luckily, the APIs of PyQt and Qt for Python are very similar. WrappersPyQt and Qt for Python both have its advantages and disadvantages. However, from a maintenance standpoint, Qt for Python wins his battle.
Most everything I’ve read, and I’m currently watching the YouTube link you provided for Burkhard Stubert at Qt Day, is regarding closed source and/or selling an application.I’m admittedly not very knowledgable in the licensing area, but I’ve been *attempting to* research this topic for the last few days. Using a wrapper is also my preferred choice for current projects.So, I have a slightly different question, or set of questions, than what I see after searching this topic. The side-by-side comparison of the advantages and disadvantages will make it easier for you to decide which Python binding for Qt to choose.If you don't want to invest too much in one or the other, you can use one of the present wrappers.
I’ve been learning PyQT5/PySide2, but I’m now wondering if the licensing will prevent me from using it.
