{"id":1661,"library":"pyqt6","title":"PyQt6","description":"PyQt6 provides Python bindings for the Qt cross-platform application development framework, allowing developers to create desktop applications with native look and feel. It is currently at version 6.11.0 and typically releases new versions in close alignment with the major and minor releases of the underlying Qt library.","status":"active","version":"6.11.0","language":"python","source_language":"en","source_url":"https://www.riverbankcomputing.com/software/pyqt/intro","tags":["GUI","Qt","desktop","widgets"],"install":[{"cmd":"pip install PyQt6","lang":"bash","label":"Install PyQt6"}],"dependencies":[],"imports":[{"symbol":"QApplication","correct":"from PyQt6.QtWidgets import QApplication"},{"symbol":"QWidget","correct":"from PyQt6.QtWidgets import QWidget"},{"symbol":"QLabel","correct":"from PyQt6.QtWidgets import QLabel"},{"symbol":"QVBoxLayout","correct":"from PyQt6.QtWidgets import QVBoxLayout"},{"note":"While some Qt enums were accessible via QtWidgets in PyQt5, PyQt6 enforces stricter module separation. Core enums like AlignmentFlag are in QtCore.","wrong":"from PyQt6.QtWidgets import Qt","symbol":"Qt","correct":"from PyQt6.QtCore import Qt"}],"quickstart":{"code":"import sys\nfrom PyQt6.QtWidgets import QApplication, QWidget, QLabel, QVBoxLayout\nfrom PyQt6.QtCore import Qt\n\nclass MyWindow(QWidget):\n    def __init__(self):\n        super().__init__()\n        self.setWindowTitle(\"My PyQt6 App\")\n        self.setGeometry(100, 100, 400, 200)\n\n        layout = QVBoxLayout()\n        label = QLabel(\"Hello, PyQt6!\", self)\n        label.setAlignment(Qt.AlignmentFlag.AlignCenter)\n        layout.addWidget(label)\n        self.setLayout(layout)\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 creates a simple desktop application window with a 'Hello, PyQt6!' label centered within it. It demonstrates the basic structure of a PyQt6 application, including `QApplication` instantiation, creating a `QWidget`, using a layout, and running the event loop."},"warnings":[{"fix":"Update all enum references to use the specific enum class (e.g., `Qt.AlignmentFlag.AlignCenter` instead of `Qt.AlignCenter`). Refer to the PyQt6 documentation for the correct enum types.","message":"Enum values (like `Qt.AlignRight`) must now be accessed via explicit enum types (e.g., `Qt.AlignmentFlag.AlignRight`, `Qt.ItemFlag.Selectable`). Direct access via `Qt.` is deprecated or removed in PyQt6.","severity":"breaking","affected_versions":"6.0.0 onwards (when migrating from PyQt5)"},{"fix":"Ensure `QApplication` is instantiated only once. In test environments or complex applications, check for an existing instance using `QApplication.instance()` before creating a new one: `app = QApplication.instance() or QApplication(sys.argv)`.","message":"The `QApplication` instance must be a singleton. Attempting to create a second `QApplication` will raise a `RuntimeError` (`RuntimeError: Application.instance() must be called before QApplication constructor`).","severity":"breaking","affected_versions":"All PyQt6 versions"},{"fix":"Offload intensive computations or I/O operations to separate threads using `QThread` or Python's `threading`/`multiprocessing` modules. Use Qt's signal/slot mechanism to communicate results back to the GUI thread for UI updates.","message":"Performing long-running or blocking operations directly on the main GUI thread will freeze your application's user interface, making it unresponsive.","severity":"gotcha","affected_versions":"All PyQt6 versions"},{"fix":"Always assign a parent to widgets where appropriate (e.g., `QLabel('Text', parent=self)`). For objects without a parent, explicitly manage their lifecycle or ensure they are properly referenced to prevent Python's garbage collector from deleting them prematurely if they are still needed by Qt.","message":"PyQt6 (Qt) objects have a parent-child ownership model. If an object has a parent, it is automatically deleted when its parent is deleted. Misunderstanding this can lead to memory leaks (orphaned objects without parents) or premature object deletion.","severity":"gotcha","affected_versions":"All PyQt6 versions"}],"env_vars":null,"search_vec":"'6.11.0':31 'align':39 'allow':15 'applic':12,20 'bind':5 'close':38 'creat':18 'cross':10 'cross-platform':9 'current':28 'desktop':19,53 'develop':13,16 'feel':25 'framework':14 'gui':51 'librari':50 'look':23 'major':42 'minor':44 'nativ':22 'new':35 'platform':11 'provid':3 'pyqt6':1,2 'python':4 'qt':8,49,52 'releas':34,45 'typic':33 'under':48 'version':30,36 'widget':54","created_at":"2026-04-09T03:57:43.191542+00:00","updated_at":"2026-04-16T19:42:33.837305+00:00","problems":[{"fix":"Install the PyQt6 package using pip: `pip install PyQt6`","cause":"The base PyQt6 library has not been installed in your Python environment.","error":"ModuleNotFoundError: No module named 'PyQt6'"},{"fix":"Install the specific missing submodule. For QtWebEngineWidgets, use: `pip install PyQt6-WebEngine` (adjust for other modules like `PyQt6-Charts` or `PyQt6-Multimedia`).","cause":"Specific optional PyQt6 modules (like WebEngine, Charts, Multimedia) need to be installed separately, even if `PyQt6` is already installed.","error":"ModuleNotFoundError: No module named 'PyQt6.QtWebEngineWidgets'"},{"fix":"Remove the parentheses when connecting a slot to pass a reference to the method: `self.button.clicked.connect(self.my_method)`","cause":"This usually occurs when connecting a signal to a slot function that has been called immediately (e.g., `self.button.clicked.connect(self.my_method())`) instead of passing a reference to the function (`self.button.clicked.connect(self.my_method)`). The function call returns `None`, which is then incorrectly passed to the `connect` method.","error":"TypeError: argument 1 has unexpected type 'NoneType'"},{"fix":"Ensure that `app = QApplication(sys.argv)` is called at the very beginning of your PyQt6 application's execution, typically before any other GUI objects are instantiated.","cause":"You are attempting to create or interact with PyQt6 GUI widgets or elements before a `QApplication` instance has been created and initialized.","error":"RuntimeError: QApplication: No instance found."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"6.11.0","cli_name":"","cli_version":null,"type":"library","homepage":"https://www.riverbankcomputing.com/software/pyqt/","github":null,"docs":null,"changelog":null,"pypi":"https://pypi.org/project/pyqt6/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["web-framework"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-27","next_check":"2026-07-28","install_tag":null}}