aboutsummaryrefslogtreecommitdiffstats
path: root/examples/declarative/extending/chapter2-methods/methods.py
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2017-09-15 15:28:29 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2017-09-15 15:09:48 +0000
commitdb336fa57497f837cfe9d58eb2d7763b33bef2e7 (patch)
tree26c7268d9d4bef941d0d63f764c143591ad2e6a1 /examples/declarative/extending/chapter2-methods/methods.py
parentaae2c80a7325f8cae47ac2fb371a5eed4b90097f (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/extending/chapter2-methods/methods.py')
-rw-r--r--examples/declarative/extending/chapter2-methods/methods.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/examples/declarative/extending/chapter2-methods/methods.py b/examples/declarative/extending/chapter2-methods/methods.py
index 847d5e5..f9bd6d3 100644
--- a/examples/declarative/extending/chapter2-methods/methods.py
+++ b/examples/declarative/extending/chapter2-methods/methods.py
@@ -93,7 +93,10 @@ if __name__ == '__main__':
view = QQuickView()
view.setResizeMode(QQuickView.SizeRootObjectToView)
- view.setSource(QUrl.fromLocalFile('app.qml'))
+ qmlFile = os.path.join(os.path.dirname(__file__), 'app.qml')
+ view.setSource(QUrl.fromLocalFile(qmlFile))
+ if view.status() == QQuickView.Error:
+ sys.exit(-1)
view.show()
res = app.exec_()
# Deleting the view before it goes out of scope is required to make sure all child QML instances