{"id":4716,"library":"pyqt6-webengine","title":"PyQt6 WebEngine","description":"PyQt6-WebEngine provides Python bindings for The Qt Company's Qt WebEngine framework, allowing developers to embed web content into their applications. It leverages Chromium, an open-source web browser project, to offer a fast and secure browsing experience. The library sits atop PyQt6, implementing the WebEngine functionality through three distinct modules. Releases typically occur roughly every six months, aligning with the upstream Qt WebEngine releases.","status":"active","version":"6.11.0","language":"en","source_language":"en","source_url":"https://www.riverbankcomputing.com/software/pyqtwebengine/","tags":["GUI","Qt","WebEngine","browser","Chromium","desktop"],"install":[{"cmd":"pip install PyQt6 PyQt6-WebEngine","lang":"bash","label":"Install PyQt6 WebEngine and its core dependency PyQt6"}],"dependencies":[{"reason":"PyQt6-WebEngine are Python bindings that sit on top of the PyQt6 framework.","package":"PyQt6"},{"reason":"Underlying Qt C++ library required for WebEngine functionality (often handled by PyQt6-WebEngine installation).","package":"qt6-webengine"}],"imports":[{"note":"In PyQt6, QtWebEngineWidgets is a separate top-level package and needs to be imported explicitly from PyQt6.QtWebEngineWidgets.","wrong":"from PyQt6 import QtWebEngineWidgets (or from PyQt5.QtWebEngineWidgets)","symbol":"QWebEngineView","correct":"from PyQt6.QtWebEngineWidgets import QWebEngineView"},{"note":"Required for setting URLs in QWebEngineView.","symbol":"QUrl","correct":"from PyQt6.QtCore import QUrl"},{"note":"The core application object for any PyQt6 application.","symbol":"QApplication","correct":"from PyQt6.QtWidgets import QApplication"}],"quickstart":{"code":"import sys\nfrom PyQt6.QtWidgets import QApplication, QWidget, QVBoxLayout\nfrom PyQt6.QtWebEngineWidgets import QWebEngineView\nfrom PyQt6.QtCore import QUrl\n\napp = QApplication(sys.argv)\n\nwindow = QWidget()\nwindow.setWindowTitle('Simple Web Browser')\nwindow.setGeometry(100, 100, 800, 600)\n\nlayout = QVBoxLayout()\nwindow.setLayout(layout)\n\nview = QWebEngineView()\nlayout.addWidget(view)\n\n# Load a URL\nview.setUrl(QUrl('https://www.google.com/'))\n\nwindow.show()\nsys.exit(app.exec())","lang":"python","description":"This basic example demonstrates how to embed a QWebEngineView widget within a PyQt6 application to display a web page. It initializes a QApplication, creates a window with a QVBoxLayout, adds a QWebEngineView, and loads Google.com."},"warnings":[{"fix":"Ensure `pyqt6-webengine` is installed (`pip install PyQt6-WebEngine`) and update imports to `from PyQt6.QtWebEngineWidgets import ...`.","message":"The QtWebEngineWidgets module, which was part of the main PyQt5 installation, has been moved to a separate `pyqt6-webengine` package for PyQt6. Direct imports from `PyQt6` (e.g., `from PyQt6 import QtWebEngineWidgets`) will fail if `pyqt6-webengine` is not explicitly installed and imported from `PyQt6.QtWebEngineWidgets`.","severity":"breaking","affected_versions":"All PyQt6 versions (6.0.0+)"},{"fix":"Always create your `QApplication` instance at the very beginning of your application's entry point before instantiating `QWebEngineView` or other related classes.","message":"Initializing QtWebEngine components (like `QWebEngineView`) sometimes requires the `QApplication` instance to be created first. Attempting to import or use `QtWebEngineWidgets` before `QApplication` is set up can lead to `ImportError: DLL load failed` or other unexpected behavior, especially on Windows.","severity":"gotcha","affected_versions":"All PyQt6 versions"},{"fix":"There is no direct fix from PyQt6-WebEngine; this is an upstream Qt issue. Consider simplifying WebGL content or exploring alternative rendering methods if this is a critical use case. Testing on different OS/hardware configurations may reveal variations in behavior.","message":"Users have reported performance issues, including flickering, with `QWebEngineView` when displaying WebGL content, particularly on Windows with secondary screens. This appears to be an upstream issue within Qt WebEngine 6.x and was less prevalent in Qt 5.15.","severity":"gotcha","affected_versions":"PyQt6-WebEngine 6.x (corresponds to Qt WebEngine 6.x)"},{"fix":"Carefully review and debug request headers. Removing unnecessary headers or ensuring they conform to expected standards can resolve such JavaScript errors.","message":"JavaScript errors within `QWebEnginePage` (accessible via `QWebEngineView.page()`) when dealing with web requests, especially authentication systems, can often be traced back to invalid or unrecognized HTTP request headers.","severity":"gotcha","affected_versions":"All PyQt6-WebEngine versions"},{"fix":"Update all enum references to their long-form (scoped) equivalents. Using `enum.Enum` or `enum.IntEnum` is the standard approach.","message":"In Qt6 (and thus PyQt6), many short-form enums (e.g., `Qt.Checked`) have been removed. Only the long-form equivalents (e.g., `Qt.CheckState.Checked`) are available. This is a general PyQt6 change but affects any code interacting with Qt APIs, including WebEngine.","severity":"breaking","affected_versions":"All PyQt6 versions (6.0.0+)"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}