PySide6 Essentials
PySide6 Essentials (version 6.11.0) provides the core Python bindings for the Qt 6 cross-platform application and UI framework. Developed by The Qt Company, it offers essential Qt modules like QtCore, QtGui, and QtWidgets under an LGPLv3 or GPLv2/GPLv3 license. It is released frequently, generally following the Qt framework's release cadence, with minor updates and bug fixes.
Warnings
- breaking When migrating from PySide2, the main module name changed from `PySide2` to `PySide6`. All imports must reflect this change.
- breaking The `QAction` class was moved from `PySide6.QtWidgets` to `PySide6.QtGui` in PySide6 compared to PySide2.
- gotcha The `pos()` and `globalPos()` methods on `QMouseEvent` are deprecated. They now return `QPointF` objects via `position()` and `globalPosition()`.
- gotcha The `QLayout.setMargin()` method has been removed. Use `QLayout.setContentsMargins()` instead.
- gotcha For better compatibility with PyQt6 (which enforces fully qualified names), prefer using fully qualified enum names like `Qt.ItemDataRole.DisplayRole` instead of shorter forms like `Qt.DisplayRole`, even though PySide6 supports both.
- gotcha When upgrading PySide6 from versions 6.2.x to 6.3 or newer, issues may arise due to the packaging split into `pyside6-essentials` and `pyside6-addons`. A direct `pip install --upgrade` might not correctly update the dependencies.
- gotcha By default, PySide6 uses `camelCase` for methods and properties, consistent with C++ Qt. To use `snake_case` (PEP8 compliant) and direct property access, you must import them from `__feature__`.
Install
-
pip install pyside6-essentials
Imports
- QApplication
from PySide6.QtWidgets import QApplication
- QWidget
from PySide6.QtWidgets import QWidget
- QLabel
from PySide6.QtWidgets import QLabel
- QPushButton
from PySide6.QtWidgets import QPushButton
- QMainWindow
from PySide6.QtWidgets import QMainWindow
- QVBoxLayout
from PySide6.QtWidgets import QVBoxLayout
- Qt
from PySide6.QtCore import Qt
- QAction
from PySide6.QtGui import QAction
Quickstart
import sys
from PySide6.QtWidgets import QApplication, QLabel, QWidget, QVBoxLayout
def main():
app = QApplication(sys.argv)
window = QWidget()
window.setWindowTitle("PySide6 Essentials App")
layout = QVBoxLayout()
label = QLabel("Hello from PySide6 Essentials!")
layout.addWidget(label)
window.setLayout(layout)
window.show()
sys.exit(app.exec())
if __name__ == "__main__":
main()