aboutsummaryrefslogtreecommitdiffstats
path: root/examples/qml/tutorials/extending-qml-advanced/advanced5-Attached-properties/doc/advanced5-Attached-properties.rst
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-05-03 14:52:06 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2023-05-10 21:29:59 +0200
commit7c5721fe74183e37bac46b42929c35c293f1ad54 (patch)
tree2ec34232eecce69bfb8e8d228286076708529d0c /examples/qml/tutorials/extending-qml-advanced/advanced5-Attached-properties/doc/advanced5-Attached-properties.rst
parent3e40f27cb539e0106511790a40327f5a03e48fab (diff)
QML reference examples: Adapt tutorial texts
Take over the texts from C++ with adaptions for Python. Task-number: PYSIDE-2206 Task-number: QTBUG-111033 Pick-to: 6.5 Change-Id: I0e4f1ec39b10bc1440389219604194b2ee001450 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'examples/qml/tutorials/extending-qml-advanced/advanced5-Attached-properties/doc/advanced5-Attached-properties.rst')
-rw-r--r--examples/qml/tutorials/extending-qml-advanced/advanced5-Attached-properties/doc/advanced5-Attached-properties.rst57
1 files changed, 48 insertions, 9 deletions
diff --git a/examples/qml/tutorials/extending-qml-advanced/advanced5-Attached-properties/doc/advanced5-Attached-properties.rst b/examples/qml/tutorials/extending-qml-advanced/advanced5-Attached-properties/doc/advanced5-Attached-properties.rst
index 95fb5c43c..14b4bddb0 100644
--- a/examples/qml/tutorials/extending-qml-advanced/advanced5-Attached-properties/doc/advanced5-Attached-properties.rst
+++ b/examples/qml/tutorials/extending-qml-advanced/advanced5-Attached-properties/doc/advanced5-Attached-properties.rst
@@ -1,12 +1,51 @@
-.. _qml-attached-properties-example:
+.. _qml-advanced-advanced5-attached-properties:
-Extending QML - Attached Properties Example
-===========================================
+Extending QML (advanced) - Attached Properties
+==============================================
-This example builds on the :ref:`qml-default-property-example`,
-:ref:`qml-inheritance-and-coercion-example`,
-:ref:`qml-object-and-list-property-types-example`
-and the :ref:`qml-adding-types-example`.
+This is the fifth of a series of 6 examples forming a tutorial using the
+example of a birthday party to demonstrate some of the advanced features of
+QML.
-The Attached Properties Example example shows how to inject
-properties to child objects.
+The time has come for the host to send out invitations. To keep track of which
+guests have responded to the invitation and when, we need somewhere to store
+that information. Storing it in the ``BirthdayParty`` object iself would not
+really fit. A better way would be to store the responses as attached objects to
+the party object.
+
+First, we declare the ``BirthdayPartyAttached`` class which holds the guest reponses.
+
+.. literalinclude:: birthdayparty.py
+ :lineno-start: 16
+ :lines: 16-32
+
+And we attach it to the ``BirthdayParty`` class and define
+``qmlAttachedProperties()`` to return the attached object.
+
+.. literalinclude:: birthdayparty.py
+ :lineno-start: 34
+ :lines: 34-38
+
+.. literalinclude:: birthdayparty.py
+ :lineno-start: 67
+ :lines: 67-69
+
+Now, attached objects can be used in the QML to hold the rsvp information of
+the invited guests.
+
+.. literalinclude:: People/Main.qml
+ :lineno-start: 6
+ :lines: 6-22
+
+Finally, the information can be accessed in the following way.
+
+.. literalinclude:: main.py
+ :lineno-start: 36
+ :lines: 36-39
+
+The program outputs the following summary of the party to come::
+
+ "Jack Smith" is having a birthday!
+ He is inviting:
+ "Robert Campbell" RSVP date: "Wed Mar 1 2023"
+ "Leo Hodges" RSVP date: "Mon Mar 6 2023"