aboutsummaryrefslogtreecommitdiffstats
path: root/examples/qml/referenceexamples/properties
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-04-28 16:46:23 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2023-05-02 16:44:37 +0200
commit9e0da8e0288d4c87eaa6f8a22ec107e04d0cd305 (patch)
tree3cde2b2b667ebd58002a19894440c47cee0cdc8e /examples/qml/referenceexamples/properties
parentfbb22873530c200b4ddb9b2da91764948bb9da71 (diff)
Move the QML reference examples around to match the structure in Qt
Adapt the tests accordingly. Task-number: PYSIDE-2206 Task-number: QTBUG-111033 Pick-to: 6.5 Change-Id: I332d6467da56b88ecbf9282d23092d8d47b730e0 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
Diffstat (limited to 'examples/qml/referenceexamples/properties')
-rw-r--r--examples/qml/referenceexamples/properties/People/Main.qml16
-rw-r--r--examples/qml/referenceexamples/properties/People/qmldir3
-rw-r--r--examples/qml/referenceexamples/properties/birthdayparty.py41
-rw-r--r--examples/qml/referenceexamples/properties/doc/properties.rst89
-rw-r--r--examples/qml/referenceexamples/properties/main.py34
-rw-r--r--examples/qml/referenceexamples/properties/person.py35
-rw-r--r--examples/qml/referenceexamples/properties/properties.pyproject4
7 files changed, 0 insertions, 222 deletions
diff --git a/examples/qml/referenceexamples/properties/People/Main.qml b/examples/qml/referenceexamples/properties/People/Main.qml
deleted file mode 100644
index 0600b3557..000000000
--- a/examples/qml/referenceexamples/properties/People/Main.qml
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-import People
-
-BirthdayParty {
- host: Person {
- name: "Bob Jones"
- shoe_size: 12
- }
- guests: [
- Person { name: "Leo Hodges" },
- Person { name: "Jack Smith" },
- Person { name: "Anne Brown" }
- ]
-}
diff --git a/examples/qml/referenceexamples/properties/People/qmldir b/examples/qml/referenceexamples/properties/People/qmldir
deleted file mode 100644
index a2bd9515a..000000000
--- a/examples/qml/referenceexamples/properties/People/qmldir
+++ /dev/null
@@ -1,3 +0,0 @@
-module People
-typeinfo coercion.qmltypes
-Main 1.0 Main.qml
diff --git a/examples/qml/referenceexamples/properties/birthdayparty.py b/examples/qml/referenceexamples/properties/birthdayparty.py
deleted file mode 100644
index 47dddc85d..000000000
--- a/examples/qml/referenceexamples/properties/birthdayparty.py
+++ /dev/null
@@ -1,41 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-from PySide6.QtCore import QObject, Property
-from PySide6.QtQml import QmlElement, ListProperty
-
-from person import Person
-
-
-# To be used on the @QmlElement decorator
-# (QML_IMPORT_MINOR_VERSION is optional)
-QML_IMPORT_NAME = "People"
-QML_IMPORT_MAJOR_VERSION = 1
-
-
-@QmlElement
-class BirthdayParty(QObject):
-
- def __init__(self, parent=None):
- super().__init__(parent)
- self._host = None
- self._guests = []
-
- @Property(Person)
- def host(self):
- return self._host
-
- @host.setter
- def host(self, h):
- self._host = h
-
- def guest(self, n):
- return self._guests[n]
-
- def guestCount(self):
- return len(self._guests)
-
- def appendGuest(self, guest):
- self._guests.append(guest)
-
- guests = ListProperty(Person, appendGuest)
diff --git a/examples/qml/referenceexamples/properties/doc/properties.rst b/examples/qml/referenceexamples/properties/doc/properties.rst
deleted file mode 100644
index fd0c6d474..000000000
--- a/examples/qml/referenceexamples/properties/doc/properties.rst
+++ /dev/null
@@ -1,89 +0,0 @@
-.. _qml-object-and-list-property-types-example:
-
-Extending QML - Object and List Property Types Example
-======================================================
-
-Exporting C++ Properties.
-
-This example builds on :ref:`qml-adding-types-example`.
-
-The Object and List Property Types example shows how to add object and list
-properties in QML. This example adds a BirthdayParty type that specifies a
-birthday party, consisting of a celebrant and a list of guests. People are
-specified using the People QML type built in the previous example.
-
-import examples.properties.people
-
-.. code-block:: javascript
-
- BirthdayParty {
- host: Person {
- name: "Bob Jones"
- shoe_size: 12
- }
- guests: [
- Person { name: "Leo Hodges" },
- Person { name: "Jack Smith" },
- Person { name: "Anne Brown" }
- ]
- }
-
-Declare the BirthdayParty
--------------------------
-
-The BirthdayParty class is declared like this:
-
-.. code-block:: python
-
- from person import Person
-
-
- # To be used on the @QmlElement decorator
- # (QML_IMPORT_MINOR_VERSION is optional)
- QML_IMPORT_NAME = "People"
- QML_IMPORT_MAJOR_VERSION = 1
-
-
- @QmlElement
- class BirthdayParty(QObject):
-
- def __init__(self, parent=None):
- super().__init__(parent)
- self._host = None
- self._guests = []
-
- @Property(Person)
- def host(self):
- return self._host
-
- @host.setter
- def host(self, h):
- self._host = h
-
- def guest(self, n):
- return self._guests[n]
-
- def guestCount(self):
- return len(self._guests)
-
- def appendGuest(self, guest):
- self._guests.append(guest)
-
- guests = ListProperty(Person, appendGuest)
-
-The class contains a member to store the celebrant object, and also a
-list member storing the Person instances.
-
-In QML, the type of a list properties - and the guests property is a list of
-people - are all of type ListProperty. ListProperty is simple value
-type that contains a set of functions. QML calls these functions
-whenever it needs to read from, write to or otherwise interact with
-the list. In addition to concrete lists like the people list used in this
-example, the use of QQmlListProperty allows for "virtual lists" and other advanced
-scenarios.
-
-Running the Example
--------------------
-
-The main.py file in the example includes a simple shell application that
-loads and runs the QML snippet shown at the beginning of this page.
diff --git a/examples/qml/referenceexamples/properties/main.py b/examples/qml/referenceexamples/properties/main.py
deleted file mode 100644
index 4797e4c7c..000000000
--- a/examples/qml/referenceexamples/properties/main.py
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-"""PySide6 port of the qml/examples/qml/referenceexamples/properties example from Qt v6.x"""
-
-from pathlib import Path
-import sys
-
-from PySide6.QtCore import QCoreApplication
-from PySide6.QtQml import QQmlComponent, QQmlEngine
-
-from person import Person
-from birthdayparty import BirthdayParty
-
-
-if __name__ == '__main__':
- app = QCoreApplication(sys.argv)
-
- engine = QQmlEngine()
- engine.addImportPath(Path(__file__).parent)
- component = QQmlComponent(engine)
- component.loadFromModule("People", "Main")
-
- party = component.create()
- if party:
- print(f"{party.host} is having a birthday!\nThey are inviting:")
- for g in range(party.guestCount()):
- name = party.guest(g).name
- print(f" {name}")
- else:
- print(component.errors())
-
- del engine
- sys.exit(0)
diff --git a/examples/qml/referenceexamples/properties/person.py b/examples/qml/referenceexamples/properties/person.py
deleted file mode 100644
index fafb9d581..000000000
--- a/examples/qml/referenceexamples/properties/person.py
+++ /dev/null
@@ -1,35 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-from PySide6.QtCore import QObject, Property
-from PySide6.QtQml import QmlElement
-
-# To be used on the @QmlElement decorator
-# (QML_IMPORT_MINOR_VERSION is optional)
-QML_IMPORT_NAME = "People"
-QML_IMPORT_MAJOR_VERSION = 1
-
-
-@QmlElement
-class Person(QObject):
- def __init__(self, parent=None):
- super().__init__(parent)
- self._name = ''
- self._shoe_size = 0
-
- @Property(str)
- def name(self):
- return self._name
-
- @name.setter
- def name(self, n):
- self._name = n
-
- @Property(int)
- def shoe_size(self):
- return self._shoe_size
-
- @shoe_size.setter
- def shoe_size(self, s):
- self._shoe_size = s
-
diff --git a/examples/qml/referenceexamples/properties/properties.pyproject b/examples/qml/referenceexamples/properties/properties.pyproject
deleted file mode 100644
index adb34b2d0..000000000
--- a/examples/qml/referenceexamples/properties/properties.pyproject
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "files": ["main.py", "person.py", "birthdayparty.py",
- "People/Main.qml", "People/qmldir"]
-}