diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-09-15 15:28:29 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-09-15 15:09:48 +0000 |
commit | db336fa57497f837cfe9d58eb2d7763b33bef2e7 (patch) | |
tree | 26c7268d9d4bef941d0d63f764c143591ad2e6a1 /examples/declarative/signals/pytoqml1/main.py | |
parent | aae2c80a7325f8cae47ac2fb371a5eed4b90097f (diff) |
Quick examples: Standardize loading code
Expand local file by directory of script and load via QUrl.
Exit on error.
Change-Id: Ia5fd36cbe9b8940e265968e91a5e5ec2b216276b
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'examples/declarative/signals/pytoqml1/main.py')
-rwxr-xr-x | examples/declarative/signals/pytoqml1/main.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/examples/declarative/signals/pytoqml1/main.py b/examples/declarative/signals/pytoqml1/main.py index 0ca1ffe..92f94fe 100755 --- a/examples/declarative/signals/pytoqml1/main.py +++ b/examples/declarative/signals/pytoqml1/main.py @@ -42,6 +42,7 @@ from __future__ import print_function +import os import sys from PySide2.QtCore import QTimer, QUrl from PySide2.QtGui import QGuiApplication @@ -55,7 +56,10 @@ if __name__ == '__main__': timer.start(2000) view = QQuickView() - view.setSource(QUrl('view.qml')) + qmlFile = os.path.join(os.path.dirname(__file__), 'view.qml') + view.setSource(QUrl.fromLocalFile(qmlFile)) + if view.status() == QQuickView.Error: + sys.exit(-1) root = view.rootObject() timer.timeout.connect(root.updateRotater) |