aboutsummaryrefslogtreecommitdiffstats
path: root/examples/bluetooth/heartrate_game/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/bluetooth/heartrate_game/main.py')
-rw-r--r--examples/bluetooth/heartrate_game/main.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/examples/bluetooth/heartrate_game/main.py b/examples/bluetooth/heartrate_game/main.py
index a101a05bf..3cb4f0672 100644
--- a/examples/bluetooth/heartrate_game/main.py
+++ b/examples/bluetooth/heartrate_game/main.py
@@ -3,19 +3,18 @@
"""PySide6 port of the bluetooth/heartrate-game example from Qt v6.x"""
-import os
from pathlib import Path
import sys
-from argparse import ArgumentParser, Namespace, RawDescriptionHelpFormatter
+from argparse import ArgumentParser, RawDescriptionHelpFormatter
-from PySide6.QtQml import QQmlApplicationEngine, QQmlContext
+from PySide6.QtQml import QQmlApplicationEngine
from PySide6.QtGui import QGuiApplication
-from PySide6.QtCore import QCoreApplication, QLoggingCategory, QUrl
+from PySide6.QtCore import QCoreApplication, QLoggingCategory
from connectionhandler import ConnectionHandler
from devicefinder import DeviceFinder
from devicehandler import DeviceHandler
-from heartrate_global import simulator
+from heartrate_global import set_simulator
if __name__ == '__main__':
@@ -27,7 +26,7 @@ if __name__ == '__main__':
parser.add_argument("-s", "--simulator", action="store_true",
help="Use Simulator")
options = parser.parse_args()
- simulator = options.simulator
+ set_simulator(options.simulator)
if options.verbose:
QLoggingCategory.setFilterRules("qt.bluetooth* = true")
@@ -43,8 +42,9 @@ if __name__ == '__main__':
"deviceFinder": deviceFinder,
"deviceHandler": deviceHandler})
- qml_file = os.fspath(Path(__file__).resolve().parent / "qml" / "main.qml")
- engine.load(QUrl.fromLocalFile(qml_file))
+ engine.addImportPath(Path(__file__).parent)
+ engine.loadFromModule("HeartRateGame", "Main")
+
if not engine.rootObjects():
sys.exit(-1)