Qt for Python release: 6.8 is out now!

We’re very happy to announce the latest release of Qt for Python 6.8. With every new release, we try to bring great things with Qt's new features and new trending ideas. For your convenience, you can check out what's new in Qt for Python 6.8 and what’s improved, along with the entire change log 

During each release, the Qt for Python team is working on a good balance of bug fixing, feature development, and completely new ideas. For this release, you will see a few changes related to improving our current offering, like changes to our signal connections for Python callables in preparation for the removal of Python's GIL, extending support for the lazy loading to include smart pointers and nested types, and a few other minor fixes.

We would like to highlight a few of the main tasks that the team invested the most time with.

Qt Design Studio compatibility

Did you hear? You can easily run your QtDS projects with a Python backend now!

In case you haven't, check out our previous blog post about the new export functionality in QtDS, and the new PySide6_DS package to include their ad-hoc QtQuick components. Additionally, you can use pyside6-deploy to deploy your Design Studio project with a Python backend. After exporting your project, simply run the following command from within the exported project using a Python environment with PySide6 installed:

pyside6-deploy Python/main.py

Binary size reduction

Wrapping Qt libraries can introduce overhead in terms of performance, but also related to the installation size. With this release, we are reducing our binary sizes by around 10%, but we believe more is possible, so we are still working on this item.

To put things in perspective, for QtCore on Linux, the Qt binary is around 6.8 MB, and the wrapper binary 4.4 MB. This means that for you to use QtCore from PySide, need around 11.2 MB, and considering the deployment of applications, this might be an issue on embedded systems, or even desktop applications.

We noticed that a few strings could be compressed, and others even removed, but we are still working on pushing the size a bit further, and manage to provide a lightweight wrapper around Qt binaries.

Improving our Python stubs (Type hints)

A few systematic issues came from the return types of some dunder methods in Shiboken's type system, which had a generic PyObject* rather than str. In some cases, mypy couldn't handle inconsistent static methods in overload chains.

Most of the files that were updated were our examples and tutorials, where the new Enums introduced a few minor versions ago are required for mypy to properly handle those lines, even with our forgiveness mode that we have in place for compatibility purposes (for example we should use Qt.Orientation.Horizontal, rather than Qt.Horizontal).

Many old bugs around typing were fixed as well, but there are still a few things to do in future releases.

Research on Dynamic Bindings

In the last months, we have been researching ways to simplify the binding generation process, more precisely, to rely on QMetaObject to provide Python dynamic bindings for QObjects. This includes a mechanism to convert types for function arguments with QMetaType and extend them with custom converters for other types as well.

This is a tricky topic, there are many details that you need to settle from the Qt side, from CPython and also for C++, so you can understand that finding a proper balance might be challenging.

One specific topic that require more work is the idea of objects ownership, which we already solved via Shiboken, but this project is something completely new. We could re-use some of the logic, but we wanted to avoid being too tight with the current offering.

We hope to blog about this topic in the near future, mostly because it provides a simpler way to enabling Scripting capabilities in Qt/C++ applications.

 

Introducing the PySide6 Flatpak Baseapp!  

While not exclusive to version 6.8, we've been diligently working on a Flatpak baseapp for PySide6. This enable PySide6 Linux developers to effortlessly create Flatpak applications using PySide6. Built on the robust KDE SDK, the baseapp comes pre-loaded with PySide6 libraries, making development smoother than ever. 

Currently, the baseapp supports only PySide6 6.7.3, and it's readily available on Flathub. The baseapp will be updated to PySide6 6.8.0 as soon as the KDE runtime updates its Qt version to 6.8.0.

To get started, simply run the following command: 

  flatpak install flathub io.qt.PySide6.BaseApp//6.7 

For an in-depth guide on using the baseapp to create your own PySide6 application, check out the fantastic tutorial in the KDE developer documentation:  https://develop.kde.org/docs/getting-started/python/ 

Android Wheels for PySide6 

With the release of PySide6 6.8, you can now download Android wheels of PySide6, which seamlessly integrate with the `pyside6-android-deploy` CLI tool. This makes it much easier to package your PySide6 applications for Android architectures. Previously, developers had to navigate the cumbersome process of cross-compiling Android PySide6 binaries themselves. This often proved to be a challenging and time-consuming task. But now, with the availability of pre-built PySide6 Android wheels, the process is streamlined and more accessible than ever 

To get started, you can download the Android wheels from the official Qt for Python release page: https://download.qt.io/official_releases/QtForPython/pyside6/ 

Alternatively, you can use the upcoming release (0.1.4) of qtpip to download the wheels directly. 

qtpip download PySide6 --android --arch aarch64   

for aarch64 wheels, or for x86_64 wheels. 

qtpip will output the path to the downloaded wheels, which you can then use with the `pyside6-android-deploy` tool to package your PySide6 application for Android. 

pyside6-android-deploy --wheel-pyside=<path_to_pyside6_wheel> --wheel-shiboken=<path_to_shiboken_wheel> --name <application_name> --ndk-path=<downloaded_ndk_path> --sdk-path=<downloaded_sdk_path>

To learn how to use pyside6-android-deploy, refer the official documentaion.  

New tool: pyside6-svgtoqml 

The PySide6 counterpart of the svgtoqml tool, that can be used to convert SVG documents into a QML file that can be used from QtQuick applications.  

pyside6-svgtoqml <svg_file_to_read> <qml_file_to_write> 

Future Plan 

In the following releases, we want to focus on improve our current offering, but at the same time we will work more in our tooling, in order to simplify programming decisions for the PySide developers, but also we will explore new ways of interacting with Python.

On the last topic, we have been researching a few ways of simplifying the Qt and Python development, mostly to reduce the amount of boilerplate code when writing simple applications, but also to provide a more independent mechanism to add the logic to a UI.

Let's stay in touch!

We want to keep trying new experimental support, features, and Python module integration. What should we do next? Drop us a message or open a suggestion on JIRA 👍. 

We hope you enjoy the release, and as always, drop by our community platforms and let us know if something is not properly working by opening bug reports.

 


Blog Topics:

Comments