aboutsummaryrefslogtreecommitdiffstats
path: root/examples/webenginewidgets/simplebrowser/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/webenginewidgets/simplebrowser/main.py')
-rw-r--r--examples/webenginewidgets/simplebrowser/main.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/examples/webenginewidgets/simplebrowser/main.py b/examples/webenginewidgets/simplebrowser/main.py
new file mode 100644
index 000000000..781ec29eb
--- /dev/null
+++ b/examples/webenginewidgets/simplebrowser/main.py
@@ -0,0 +1,45 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+"""PySide6 port of the Qt WebEngineWidgets Simple Browser example from Qt v6.x"""
+
+import sys
+from argparse import ArgumentParser, RawTextHelpFormatter
+
+from PySide6.QtWebEngineCore import QWebEngineProfile, QWebEngineSettings
+from PySide6.QtWidgets import QApplication
+from PySide6.QtGui import QIcon
+from PySide6.QtCore import QCoreApplication, QLoggingCategory, QUrl
+
+from browser import Browser
+
+import data.rc_simplebrowser # noqa: F401
+
+if __name__ == "__main__":
+ parser = ArgumentParser(description="Qt Widgets Web Browser",
+ formatter_class=RawTextHelpFormatter)
+ parser.add_argument("--single-process", "-s", action="store_true",
+ help="Run in single process mode (trouble shooting)")
+ parser.add_argument("url", type=str, nargs="?", help="URL")
+ args = parser.parse_args()
+
+ QCoreApplication.setOrganizationName("QtExamples")
+
+ app_args = sys.argv
+ if args.single_process:
+ app_args.extend(["--webEngineArgs", "--single-process"])
+ app = QApplication(app_args)
+ app.setWindowIcon(QIcon(":AppLogoColor.png"))
+ QLoggingCategory.setFilterRules("qt.webenginecontext.debug=true")
+
+ s = QWebEngineProfile.defaultProfile().settings()
+ s.setAttribute(QWebEngineSettings.PluginsEnabled, True)
+ s.setAttribute(QWebEngineSettings.DnsPrefetchEnabled, True)
+
+ browser = Browser()
+ window = browser.create_hidden_window()
+
+ url = QUrl.fromUserInput(args.url) if args.url else QUrl("https://www.qt.io")
+ window.tab_widget().set_url(url)
+ window.show()
+ sys.exit(app.exec())