diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-09-17 07:58:18 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-09-17 17:15:47 +0200 |
commit | 69d43ea814788a18e8d77920d493fd84f6fc699a (patch) | |
tree | 196e035ffca4cfe521ce9268118a03e2e1fd0651 /examples/quick/painteditem/painteditem.py | |
parent | 41522805c65ab2de956e4bb636172a3b9bcfdfcb (diff) |
Fix Qt Quick painteditem example to run from a different directory
Use the Path mechanism to resolve the QML file.
Task-number: PYSIDE-1662
Change-Id: I2d6cce02063fab6746d2cdbc7c8c8701fad7e937
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'examples/quick/painteditem/painteditem.py')
-rw-r--r-- | examples/quick/painteditem/painteditem.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/examples/quick/painteditem/painteditem.py b/examples/quick/painteditem/painteditem.py index 4d49690d8..04a9116a8 100644 --- a/examples/quick/painteditem/painteditem.py +++ b/examples/quick/painteditem/painteditem.py @@ -1,6 +1,6 @@ ############################################################################# ## -## Copyright (C) 2020 The Qt Company Ltd. +## Copyright (C) 2021 The Qt Company Ltd. ## Contact: http://www.qt.io/licensing/ ## ## This file is part of the Qt for Python examples of the Qt Toolkit. @@ -38,6 +38,7 @@ ## ############################################################################# +from pathlib import Path import sys from PySide6.QtGui import QPainter, QBrush, QColor @@ -97,7 +98,8 @@ if __name__ == "__main__": view = QQuickView() view.setResizeMode(QQuickView.SizeRootObjectToView) qmlRegisterType(TextBalloon, "TextBalloonPlugin", 1, 0, "TextBalloon") - view.setSource(QUrl.fromLocalFile("main.qml")) + qml_file = Path(__file__).parent / "main.qml" + view.setSource(QUrl.fromLocalFile(qml_file)) if view.status() == QQuickView.Error: sys.exit(-1) |