diff options
Diffstat (limited to 'examples/qml/tutorials/extending-qml/chapter2-methods')
| -rw-r--r-- | examples/qml/tutorials/extending-qml/chapter2-methods/Charts/App.qml (renamed from examples/qml/tutorials/extending-qml/chapter2-methods/app.qml) | 8 | ||||
| -rw-r--r-- | examples/qml/tutorials/extending-qml/chapter2-methods/Charts/qmldir | 4 | ||||
| -rw-r--r-- | examples/qml/tutorials/extending-qml/chapter2-methods/chapter2-methods.pyproject | 2 | ||||
| -rw-r--r-- | examples/qml/tutorials/extending-qml/chapter2-methods/methods.py | 7 |
4 files changed, 10 insertions, 11 deletions
diff --git a/examples/qml/tutorials/extending-qml/chapter2-methods/app.qml b/examples/qml/tutorials/extending-qml/chapter2-methods/Charts/App.qml index d9477e253..6190cbc50 100644 --- a/examples/qml/tutorials/extending-qml/chapter2-methods/app.qml +++ b/examples/qml/tutorials/extending-qml/chapter2-methods/Charts/App.qml @@ -1,4 +1,4 @@ -// Copyright (C) 2016 The Qt Company Ltd. +// Copyright (C) 2017 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause import Charts @@ -22,11 +22,7 @@ Item { } Text { - anchors { - bottom: parent.bottom; - horizontalCenter: parent.horizontalCenter; - bottomMargin: 20 - } + anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 } text: "Click anywhere to clear the chart" } } diff --git a/examples/qml/tutorials/extending-qml/chapter2-methods/Charts/qmldir b/examples/qml/tutorials/extending-qml/chapter2-methods/Charts/qmldir new file mode 100644 index 000000000..dad537878 --- /dev/null +++ b/examples/qml/tutorials/extending-qml/chapter2-methods/Charts/qmldir @@ -0,0 +1,4 @@ +module Charts +typeinfo chapter2-methods.qmltypes +depends QtQuick +App 254.0 App.qml diff --git a/examples/qml/tutorials/extending-qml/chapter2-methods/chapter2-methods.pyproject b/examples/qml/tutorials/extending-qml/chapter2-methods/chapter2-methods.pyproject index cdf33be7f..b0942a27b 100644 --- a/examples/qml/tutorials/extending-qml/chapter2-methods/chapter2-methods.pyproject +++ b/examples/qml/tutorials/extending-qml/chapter2-methods/chapter2-methods.pyproject @@ -1,3 +1,3 @@ { - "files": ["methods.py", "app.qml"] + "files": ["methods.py", "Charts/App.qml", "Charts/qmldir"] } diff --git a/examples/qml/tutorials/extending-qml/chapter2-methods/methods.py b/examples/qml/tutorials/extending-qml/chapter2-methods/methods.py index 238225fd3..02f600d1b 100644 --- a/examples/qml/tutorials/extending-qml/chapter2-methods/methods.py +++ b/examples/qml/tutorials/extending-qml/chapter2-methods/methods.py @@ -4,11 +4,10 @@ from __future__ import annotations """PySide6 port of the qml/tutorials/extending-qml/chapter2-methods example from Qt v5.x""" -import os from pathlib import Path import sys -from PySide6.QtCore import Property, Signal, Slot, Qt, QUrl +from PySide6.QtCore import Property, Signal, Slot, Qt from PySide6.QtGui import QGuiApplication, QPen, QPainter, QColor from PySide6.QtQml import QmlElement from PySide6.QtQuick import QQuickPaintedItem, QQuickView @@ -64,8 +63,8 @@ if __name__ == '__main__': view = QQuickView() view.setResizeMode(QQuickView.ResizeMode.SizeRootObjectToView) - qml_file = os.fspath(Path(__file__).resolve().parent / 'app.qml') - view.setSource(QUrl.fromLocalFile(qml_file)) + view.engine().addImportPath(Path(__file__).parent) + view.loadFromModule("Charts", "App") if view.status() == QQuickView.Status.Error: sys.exit(-1) view.show() |
