aboutsummaryrefslogtreecommitdiffstats
path: root/examples/qml/tutorials/extending-qml/chapter2-methods
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2025-09-11 16:06:11 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2025-09-15 16:34:14 +0200
commit5b19e261d5a4d6c28ad25f4bb29a0d5abcd1c947 (patch)
treecddfcf6acf26b6f851ba976d8046a493980fa7fd /examples/qml/tutorials/extending-qml/chapter2-methods
parent0ad827ba2f02b0b47466a81d352194c685cb02bb (diff)
Update the QML basic extending tutorials
Adapt to qtdeclarative/bb6cde5229bd15f6e233262ae46fffeda666cf3d. Pick-to: 6.10 Change-Id: Id6d7f15efbe776987a88779a769653b92d44608c Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
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/qmldir4
-rw-r--r--examples/qml/tutorials/extending-qml/chapter2-methods/chapter2-methods.pyproject2
-rw-r--r--examples/qml/tutorials/extending-qml/chapter2-methods/methods.py7
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()