diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2025-09-11 16:06:11 +0200 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2025-09-15 16:34:14 +0200 |
| commit | 5b19e261d5a4d6c28ad25f4bb29a0d5abcd1c947 (patch) | |
| tree | cddfcf6acf26b6f851ba976d8046a493980fa7fd /examples/qml/tutorials/extending-qml/chapter1-basics | |
| parent | 0ad827ba2f02b0b47466a81d352194c685cb02bb (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/chapter1-basics')
| -rw-r--r-- | examples/qml/tutorials/extending-qml/chapter1-basics/Charts/App.qml (renamed from examples/qml/tutorials/extending-qml/chapter1-basics/app.qml) | 8 | ||||
| -rw-r--r-- | examples/qml/tutorials/extending-qml/chapter1-basics/Charts/qmldir | 4 | ||||
| -rw-r--r-- | examples/qml/tutorials/extending-qml/chapter1-basics/basics.py | 7 | ||||
| -rw-r--r-- | examples/qml/tutorials/extending-qml/chapter1-basics/chapter1-basics.pyproject | 2 |
4 files changed, 10 insertions, 11 deletions
diff --git a/examples/qml/tutorials/extending-qml/chapter1-basics/app.qml b/examples/qml/tutorials/extending-qml/chapter1-basics/Charts/App.qml index 6feef5633..523dc7128 100644 --- a/examples/qml/tutorials/extending-qml/chapter1-basics/app.qml +++ b/examples/qml/tutorials/extending-qml/chapter1-basics/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 @@ -16,11 +16,7 @@ Item { } Text { - anchors { - bottom: parent.bottom; - horizontalCenter: parent.horizontalCenter; - bottomMargin: 20 - } + anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 } text: aPieChart.name } } diff --git a/examples/qml/tutorials/extending-qml/chapter1-basics/Charts/qmldir b/examples/qml/tutorials/extending-qml/chapter1-basics/Charts/qmldir new file mode 100644 index 000000000..78602c6b4 --- /dev/null +++ b/examples/qml/tutorials/extending-qml/chapter1-basics/Charts/qmldir @@ -0,0 +1,4 @@ +module Charts +typeinfo chapter1-basics.qmltypes +depends QtQuick +App 254.0 App.qml diff --git a/examples/qml/tutorials/extending-qml/chapter1-basics/basics.py b/examples/qml/tutorials/extending-qml/chapter1-basics/basics.py index 322bef954..08fa91c14 100644 --- a/examples/qml/tutorials/extending-qml/chapter1-basics/basics.py +++ b/examples/qml/tutorials/extending-qml/chapter1-basics/basics.py @@ -4,11 +4,10 @@ from __future__ import annotations """PySide6 port of the qml/tutorials/extending-qml/chapter1-basics example from Qt v5.x""" -import os from pathlib import Path import sys -from PySide6.QtCore import Property, Signal, QUrl +from PySide6.QtCore import Property, Signal from PySide6.QtGui import QGuiApplication, QPen, QPainter, QColor from PySide6.QtQml import QmlElement from PySide6.QtQuick import QQuickPaintedItem, QQuickView @@ -57,8 +56,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() diff --git a/examples/qml/tutorials/extending-qml/chapter1-basics/chapter1-basics.pyproject b/examples/qml/tutorials/extending-qml/chapter1-basics/chapter1-basics.pyproject index 869556bb8..2207b8344 100644 --- a/examples/qml/tutorials/extending-qml/chapter1-basics/chapter1-basics.pyproject +++ b/examples/qml/tutorials/extending-qml/chapter1-basics/chapter1-basics.pyproject @@ -1,3 +1,3 @@ { - "files": ["basics.py", "app.qml"] + "files": ["basics.py", "Charts/App.qml", "Charts/qmldir"] } |
