diff options
author | Friedemann Kleint <[email protected]> | 2017-10-13 16:35:40 +0200 |
---|---|---|
committer | Friedemann Kleint <[email protected]> | 2017-10-13 16:35:52 +0200 |
commit | bd0c77f81fcc66e2cd57d78123bd1ea5ece3cb28 (patch) | |
tree | 757aebd9db2e1198f3c1d5bacbddfb25a45c8a3c /examples/declarative | |
parent | 29bf933c9244883b570a9d53e900415fdcf7d437 (diff) | |
parent | b43152d1708b51f7d5c62c7a249c776354f745f5 (diff) |
Change-Id: I7f2e832b6642d84028a2a2fb39c6ac896136b7c3
Diffstat (limited to 'examples/declarative')
12 files changed, 56 insertions, 14 deletions
diff --git a/examples/declarative/extending/chapter1-basics/basics.py b/examples/declarative/extending/chapter1-basics/basics.py index 64d7ad0..2ed02fd 100644 --- a/examples/declarative/extending/chapter1-basics/basics.py +++ b/examples/declarative/extending/chapter1-basics/basics.py @@ -88,7 +88,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 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 diff --git a/examples/declarative/extending/chapter3-bindings/bindings.py b/examples/declarative/extending/chapter3-bindings/bindings.py index 47e02a6..e87d3f4 100644 --- a/examples/declarative/extending/chapter3-bindings/bindings.py +++ b/examples/declarative/extending/chapter3-bindings/bindings.py @@ -98,7 +98,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 diff --git a/examples/declarative/extending/chapter4-customPropertyTypes/customPropertyTypes.py b/examples/declarative/extending/chapter4-customPropertyTypes/customPropertyTypes.py index 4b936fa..fd94991 100644 --- a/examples/declarative/extending/chapter4-customPropertyTypes/customPropertyTypes.py +++ b/examples/declarative/extending/chapter4-customPropertyTypes/customPropertyTypes.py @@ -103,7 +103,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 diff --git a/examples/declarative/extending/chapter5-listproperties/listproperties.py b/examples/declarative/extending/chapter5-listproperties/listproperties.py index a6b270b..718691f 100644 --- a/examples/declarative/extending/chapter5-listproperties/listproperties.py +++ b/examples/declarative/extending/chapter5-listproperties/listproperties.py @@ -116,7 +116,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 diff --git a/examples/declarative/scrolling.py b/examples/declarative/scrolling.py index a614c70..ff704c4 100755 --- a/examples/declarative/scrolling.py +++ b/examples/declarative/scrolling.py @@ -42,6 +42,7 @@ from __future__ import print_function +import os import sys from PySide2.QtCore import QUrl from PySide2.QtGui import QGuiApplication @@ -60,8 +61,10 @@ if __name__ == '__main__': ctxt = view.rootContext() ctxt.setContextProperty("myModel", dataList) - url = QUrl('view.qml') - view.setSource(url) + qmlFile = os.path.join(os.path.dirname(__file__), 'view.qml') + view.setSource(QUrl.fromLocalFile(qmlFile)) + if view.status() == QQuickView.Error: + sys.exit(-1) view.show() app.exec_() 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) diff --git a/examples/declarative/signals/qmltopy1/main.py b/examples/declarative/signals/qmltopy1/main.py index 1ce0507..683169e 100755 --- a/examples/declarative/signals/qmltopy1/main.py +++ b/examples/declarative/signals/qmltopy1/main.py @@ -42,6 +42,7 @@ from __future__ import print_function +import os import sys from PySide2.QtCore import QObject, QUrl, Slot from PySide2.QtGui import QGuiApplication @@ -76,7 +77,10 @@ if __name__ == '__main__': context = view.rootContext() context.setContextProperty("con", con) - 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) view.show() res = app.exec_() # Deleting the view before it goes out of scope is required to make sure all child QML instances diff --git a/examples/declarative/signals/qmltopy2/main.py b/examples/declarative/signals/qmltopy2/main.py index 2526ede..bb84f27 100755 --- a/examples/declarative/signals/qmltopy2/main.py +++ b/examples/declarative/signals/qmltopy2/main.py @@ -42,6 +42,7 @@ from __future__ import print_function +import os import sys from PySide2.QtCore import QObject, QUrl, Slot from PySide2.QtGui import QGuiApplication @@ -68,7 +69,10 @@ if __name__ == '__main__': context = view.rootContext() context.setContextProperty("rotatevalue", rotatevalue) - 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) view.show() res = app.exec_() # Deleting the view before it goes out of scope is required to make sure all child QML instances diff --git a/examples/declarative/signals/qmltopy3/main.py b/examples/declarative/signals/qmltopy3/main.py index f2ddd49..c78c77a 100755 --- a/examples/declarative/signals/qmltopy3/main.py +++ b/examples/declarative/signals/qmltopy3/main.py @@ -42,6 +42,7 @@ from __future__ import print_function +import os import sys from PySide2.QtCore import QObject, QUrl from PySide2.QtGui import QGuiApplication @@ -54,7 +55,10 @@ def sayThis(s): if __name__ == '__main__': app = QGuiApplication(sys.argv) 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() root.textRotationChanged.connect(sayThis) diff --git a/examples/declarative/signals/qmltopy4/main.py b/examples/declarative/signals/qmltopy4/main.py index fb6fc3e..9eb9d41 100755 --- a/examples/declarative/signals/qmltopy4/main.py +++ b/examples/declarative/signals/qmltopy4/main.py @@ -42,6 +42,7 @@ from __future__ import print_function +import os import sys from PySide2.QtCore import QObject, QUrl from PySide2.QtGui import QGuiApplication @@ -54,7 +55,10 @@ def sayThis(s): if __name__ == '__main__': app = QGuiApplication(sys.argv) 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() button = root.findChild(QObject, "buttonMouseArea") diff --git a/examples/declarative/usingmodel.py b/examples/declarative/usingmodel.py index cbb334e..7d73990 100644 --- a/examples/declarative/usingmodel.py +++ b/examples/declarative/usingmodel.py @@ -42,8 +42,9 @@ from __future__ import print_function +import os import sys -from PySide2.QtCore import QAbstractListModel, Qt +from PySide2.QtCore import QAbstractListModel, Qt, QUrl from PySide2.QtGui import QGuiApplication import PySide2.QtQml from PySide2.QtQuick import QQuickView @@ -89,7 +90,10 @@ if __name__ == '__main__': myModel.populate() view.rootContext().setContextProperty("myModel", myModel) - view.setSource('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) view.show() app.exec_() |