{"id":3239,"library":"pyside6","title":"PySide6","description":"PySide6 is the official Python binding for the Qt cross-platform application and UI framework, providing access to the complete Qt 6.0+ framework. It enables Python developers to create robust and visually appealing graphical user interface (GUI) applications for desktop and other platforms. Currently at version 6.11.0, PySide6 is actively maintained by The Qt Company with releases often synchronized with the underlying Qt framework.","status":"active","version":"6.11.0","language":"en","source_language":"en","source_url":"https://github.com/pyside/pyside-setup","tags":["GUI","Qt","cross-platform","desktop-app","UI","bindings"],"install":[{"cmd":"pip install PySide6","lang":"bash","label":"Install PySide6"}],"dependencies":[{"reason":"Shiboken6 is the binding generator tool used by PySide6 to expose C++ projects to Python, and is a core component of the Qt for Python project, often installed alongside PySide6.","package":"shiboken6","optional":false}],"imports":[{"symbol":"QApplication","correct":"from PySide6.QtWidgets import QApplication"},{"symbol":"QMainWindow","correct":"from PySide6.QtWidgets import QMainWindow"},{"symbol":"QWidget","correct":"from PySide6.QtWidgets import QWidget"},{"symbol":"QLabel","correct":"from PySide6.QtWidgets import QLabel"},{"symbol":"QPushButton","correct":"from PySide6.QtWidgets import QPushButton"},{"symbol":"QVBoxLayout","correct":"from PySide6.QtWidgets import QVBoxLayout"},{"note":"QAction was moved from QtWidgets to QtGui in Qt6/PySide6.","wrong":"from PySide6.QtWidgets import QAction","symbol":"QAction","correct":"from PySide6.QtGui import QAction"},{"symbol":"Qt (for enums like alignment)","correct":"from PySide6.QtCore import Qt"}],"quickstart":{"code":"import sys\nfrom PySide6.QtWidgets import QApplication, QMainWindow, QLabel, QVBoxLayout, QWidget, QPushButton\nfrom PySide6.QtCore import Qt\n\nclass MyWindow(QMainWindow):\n    def __init__(self):\n        super().__init__()\n        self.setWindowTitle('PySide6 Hello World!')\n        self.setGeometry(100, 100, 400, 200)\n\n        layout = QVBoxLayout()\n        label = QLabel('Hello, PySide6!')\n        label.setAlignment(Qt.AlignCenter)\n        layout.addWidget(label)\n\n        button = QPushButton('Click Me!')\n        button.clicked.connect(self.on_button_click)\n        layout.addWidget(button)\n\n        container = QWidget()\n        container.setLayout(layout)\n        self.setCentralWidget(container)\n\n    def on_button_click(self):\n        print('Button clicked!')\n        self.centralWidget().findChild(QLabel).setText('You clicked the button!')\n\nif __name__ == '__main__':\n    app = QApplication(sys.argv)\n    window = MyWindow()\n    window.show()\n    sys.exit(app.exec())","lang":"python","description":"This quickstart code creates a basic PySide6 application with a main window, a label displaying 'Hello, PySide6!', and a button. Clicking the button changes the label's text and prints a message to the console. It demonstrates fundamental concepts like QApplication, QMainWindow, widgets, layouts, and signal/slot connections."},"warnings":[{"fix":"Replace `from PySide2` with `from PySide6` in all import statements.","message":"When migrating from PySide2 to PySide6, the primary change required is updating import statements from `PySide2.*` to `PySide6.*`.","severity":"breaking","affected_versions":"All versions when migrating from PySide2"},{"fix":"Update imports for `QAction` to `from PySide6.QtGui import QAction`.","message":"The `QAction` class, used for creating toolbars and menus, has been moved from `PySide6.QtWidgets` to `PySide6.QtGui` in Qt6.","severity":"breaking","affected_versions":"All PySide6 versions (vs. PySide2)"},{"fix":"Remove any explicit High DPI scaling attributes from your application initialization code.","message":"High DPI (dots per inch) scaling is enabled by default in Qt6. The previously used attributes like `Qt.AA_EnableHighDpiScaling` and `Qt.AA_UseHighDpiPixmaps` are deprecated and have no effect.","severity":"breaking","affected_versions":"All PySide6 versions (vs. PySide2)"},{"fix":"If integer coordinates are strictly required, convert the `QPointF` to `QPoint` using `.toPoint()`, e.g., `event.pos().toPoint()`.","message":"`QMouseEvent.pos()` and `QMouseEvent.globalPos()` now return a `QPointF` object (floating-point coordinates), unlike in Qt5 where they returned integer tuples.","severity":"gotcha","affected_versions":"All PySide6 versions (vs. PySide2)"},{"fix":"Replace calls to `exec_()` with `exec()`.","message":"Functions named `exec_()` (e.g., `QApplication.exec_()`, `QDialog.exec_()`) have been renamed to `exec()` in PySide6 to avoid conflict with the `exec` keyword in Python 3.","severity":"gotcha","affected_versions":"All PySide6 versions (vs. PySide2)"},{"fix":"For enums, use their full path (e.g., `QtCore.Qt.AlignmentFlag.AlignCenter`) or import the specific enum class if available.","message":"Qt Enums no longer necessarily inherit to the top-level `Qt` object. For example, `Qt.AlignCenter` might not be directly accessible and requires explicit import or a more specific path.","severity":"gotcha","affected_versions":"All PySide6 versions (vs. PySide2)"},{"fix":"Decide on a consistent naming convention. If using `snake_case`, ensure all new code and potentially existing code (or auto-generated UI code) adheres to it to avoid mixed styles.","message":"PySide6 offers an experimental `snake_case` feature (via `from __feature__ import snake_case`) to align method naming with PEP8. However, this is an opt-in feature and can lead to inconsistent code if not applied uniformly across a project, especially with auto-generated UI code.","severity":"gotcha","affected_versions":"All PySide6 versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}