Modules Within PySide6 for Cross-platform GUI Building and System API Calling

A Brief Introduction to Qt

Qt is a C++ library with official Python bindings that allows creating GUIs and cross-platform applications targeting different software and hardware platforms, such as Linux, Windows, macOS, Android, or embedded systems, with little to no change to the underlying codebase, while still having native capabilities, speed, and "look and feel".

There are several advantages of using Qt, including:

  • Well-designed object-oriented framework.
  • Excellent documentation.
  • Large user base.
  • Widely endorsed. Many industrial-grade cross-platform software use Qt, including Autodesk Maya, Autodesk 3ds Max, Google Earth, Mathematica, OBS Studio, QGIS, Sibelius, Teamviewer, VirtualBox, VLC media player, Wireshark, and WPS Office.

Modules Within PySide6

To aid use, we have summarized the relevant modules of PySide6, Qt's official Python bindings.

  • PySide6.QtCore: Qt's essential classes, including platform-independent command-line parsing, multithreading, date and time utilities, object serialization, etc. Most of these features have already been introduced into the C++ and Python standard libraries. However, we should pay attention to Qt's event handling mechanism - a mechanism for emitting events in the form of objects across threads (known as signals), and handling these events in designated functions (known as slots).

The modules of PySide6 directly related to building GUIs are as follows:

  • PySide6.QtGui: Classes used internally by Qt's user interface technologies, including classes for windowing system integration, event handling, OpenGL and OpenGL ES integration, 2D graphics, basic imaging, fonts, and text.
  • PySide6.QtWidgets: Provides a set of UI elements to create classic desktop-style user interfaces. All UI elements, including user-defined ones, inherit from PySide6.QtWidgets.QtWidget.
  • PySide6.QtMultimediaWidgets: Provides multimedia-related widgets and controls.
  • PySide6.QtOpenGL, PySide6.QtOpenGLWidgets: Used to support the OpenGL widget class, which operates similarly to other Qt widgets with the exception that it opens an OpenGL display buffer whose contents can be rendered using the OpenGL API.
  • PySide6.QtPdf, PySide6.QtPdfWidgets: Classes for rendering pages from PDF documents.
  • PySide6.QtWebEngineCore, PySide6.QtWebEngineWidgets: Provides a Chromium web browser engine as well as C++ classes to render web content and interact with it.

Qt is more than a GUI framework. It also provides a cross-platform way of doing a lot of stuff that desktop applications often need to do - calling into system APIs, especially platform-specific multimedia APIs not covered by the POSIX standard and/or the C++ and Python standard libraries.

Stock Image: Multimedia

To better document this crucial yet often overlooked use case, we have summarized the relevant modules of PySide6.

  • PySide6.QtBluetooth: Enables connectivity between Bluetooth enabled devices. Currently the API is supported to different degrees on Android, iOS, macOS, Linux, and Windows.
  • PySide6.QtMultimedia: Provides APIs for rendering audio and video files on screen and playing them back, as well as a thorough API for recording audio and video via system cameras and microphones.
  • PySide6.QtNfc: Provides APIs for dealing with NFC Forum Tags and NFC Forum Devices, including target identification and loss, the registration of NDEF message handlers, the reading and writing of NDEF messages on NFC Forum Tags, and the sending of tag-specific commands.
  • PySide6.QtPositioning: Allows developers to locate themselves using a variety of sources, such as satellite, wifi, text files, and so on. The position on a map, for instance, can be determined using that information. Additionally, it is possible to retrieve satellite data and carry out area-based monitoring. Currently the API is supported on Android, iOS, macOS, Linux, and Windows (with GPS receivers exposed as a serial port providing NMEA sentences or using Windows.Devices.Geolocation).
  • PySide6.QtPrintSupport: Offers broad cross-platform printing capability, including printing to attached printers, printing to remote printers over networks, and creating PDF files.
  • PySide6.QtSensors: Provides access to sensor hardware. Currently the API is supported on Android, iOS, and Windows (MSVC).

References:

  • https://en.wikipedia.org/wiki/Qt_(software)
  • https://www.quora.com/What-are-the-Pros-and-Cons-of-using-QT-framework-for-cross-platform-programming-Win-Mac
  • https://wiki.qt.io/Qt_for_Python

Modules Within PySide6 for Cross-platform GUI Building and System API Calling
https://abbaswu.github.io/2023/01/02/Modules-Within-PySide6-for-Cross-platform-GUI-Building-and-System-API-Calling/
Author
Jifeng Wu
Posted on
January 2, 2023
Licensed under