diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-04-28 11:47:23 +0200 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-05-02 16:44:15 +0200 |
| commit | fbb22873530c200b4ddb9b2da91764948bb9da71 (patch) | |
| tree | 88c64bde71483b6f68c5770e145268282f856c8f /examples/qml/referenceexamples/methods | |
| parent | 2c166425cf4143a6c5f6744ffa959a1b77b13e36 (diff) | |
Port the QML reference examples to QML module usage
As a drive-by fix the example origin where applicable.
Task-number: PYSIDE-2206
Task-number: QTBUG-111033
Pick-to: 6.5
Change-Id: If3b17435c17310c3f6c196f7653c7025ad359366
Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
Diffstat (limited to 'examples/qml/referenceexamples/methods')
| -rw-r--r-- | examples/qml/referenceexamples/methods/People/Main.qml (renamed from examples/qml/referenceexamples/methods/example.qml) | 2 | ||||
| -rw-r--r-- | examples/qml/referenceexamples/methods/People/qmldir | 3 | ||||
| -rw-r--r-- | examples/qml/referenceexamples/methods/birthdayparty.py | 2 | ||||
| -rw-r--r-- | examples/qml/referenceexamples/methods/main.py | 8 | ||||
| -rw-r--r-- | examples/qml/referenceexamples/methods/methods.pyproject | 3 | ||||
| -rw-r--r-- | examples/qml/referenceexamples/methods/person.py | 2 |
6 files changed, 12 insertions, 8 deletions
diff --git a/examples/qml/referenceexamples/methods/example.qml b/examples/qml/referenceexamples/methods/People/Main.qml index c48e952fd..69b2119ab 100644 --- a/examples/qml/referenceexamples/methods/example.qml +++ b/examples/qml/referenceexamples/methods/People/Main.qml @@ -2,7 +2,7 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause import QtQuick -import examples.methods.people +import People BirthdayParty { host: Person { diff --git a/examples/qml/referenceexamples/methods/People/qmldir b/examples/qml/referenceexamples/methods/People/qmldir new file mode 100644 index 000000000..a2bd9515a --- /dev/null +++ b/examples/qml/referenceexamples/methods/People/qmldir @@ -0,0 +1,3 @@ +module People +typeinfo coercion.qmltypes +Main 1.0 Main.qml diff --git a/examples/qml/referenceexamples/methods/birthdayparty.py b/examples/qml/referenceexamples/methods/birthdayparty.py index 41425a2b1..a3942b671 100644 --- a/examples/qml/referenceexamples/methods/birthdayparty.py +++ b/examples/qml/referenceexamples/methods/birthdayparty.py @@ -9,7 +9,7 @@ from person import Person # To be used on the @QmlElement decorator # (QML_IMPORT_MINOR_VERSION is optional) -QML_IMPORT_NAME = "examples.methods.people" +QML_IMPORT_NAME = "People" QML_IMPORT_MAJOR_VERSION = 1 diff --git a/examples/qml/referenceexamples/methods/main.py b/examples/qml/referenceexamples/methods/main.py index 31748ff2b..5f51ebe1f 100644 --- a/examples/qml/referenceexamples/methods/main.py +++ b/examples/qml/referenceexamples/methods/main.py @@ -6,7 +6,7 @@ from pathlib import Path import sys -from PySide6.QtCore import QCoreApplication, QUrl +from PySide6.QtCore import QCoreApplication from PySide6.QtQml import QQmlComponent, QQmlEngine from person import Person @@ -14,10 +14,10 @@ from birthdayparty import BirthdayParty app = QCoreApplication(sys.argv) -qml_file = Path(__file__).parent / "example.qml" -url = QUrl.fromLocalFile(qml_file) engine = QQmlEngine() -component = QQmlComponent(engine, url) +engine.addImportPath(Path(__file__).parent) +component = QQmlComponent(engine) +component.loadFromModule("People", "Main") party = component.create() if not party: print(component.errors()) diff --git a/examples/qml/referenceexamples/methods/methods.pyproject b/examples/qml/referenceexamples/methods/methods.pyproject index 3c01c40c2..09942ebcc 100644 --- a/examples/qml/referenceexamples/methods/methods.pyproject +++ b/examples/qml/referenceexamples/methods/methods.pyproject @@ -1,3 +1,4 @@ { - "files": ["main.py", "birthdayparty.py", "person.py", "example.qml"] + "files": ["main.py", "birthdayparty.py", "person.py", + "People/Main.qml", "People/qmldir"] } diff --git a/examples/qml/referenceexamples/methods/person.py b/examples/qml/referenceexamples/methods/person.py index b5e0bd899..526eae714 100644 --- a/examples/qml/referenceexamples/methods/person.py +++ b/examples/qml/referenceexamples/methods/person.py @@ -6,7 +6,7 @@ from PySide6.QtQml import QmlElement # To be used on the @QmlElement decorator # (QML_IMPORT_MINOR_VERSION is optional) -QML_IMPORT_NAME = "examples.methods.people" +QML_IMPORT_NAME = "People" QML_IMPORT_MAJOR_VERSION = 1 |
