aboutsummaryrefslogtreecommitdiffstats
path: root/examples/qml/tutorials/extending-qml-advanced/advanced4-Grouped-properties/doc/advanced4-Grouped-properties.rst
blob: 7748d3189050299f9da25893694780db9b96d489 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
.. _qml-advanced-advanced4-grouped-properties:

Extending QML (advanced) - Grouped Properties
=============================================

This is the fourth 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.

More information is needed about the shoes of the guests. Aside from their
size, we also want to store the shoes' color, brand, and price. This
information is stored in a ``ShoeDescription`` class.

.. literalinclude:: person.py
    :lineno-start: 14
    :lines: 14-66

Each person now has two properties, a ``name`` and a shoe description ``shoe``.

.. literalinclude:: person.py
    :lineno-start: 69
    :lines: 69-90

Specifying the values for each element of the shoe description works but is a
bit repetitive.

.. literalinclude:: People/Main.qml
    :lineno-start: 26
    :lines: 26-32

Grouped properties provide a more elegant way of assigning these properties.
Instead of assigning the values to each property one-by-one, the individual
values can be passed as a group to the ``shoe`` property making the code more
readable. No changes are required to enable this feature as it is available by
default for all of QML.

.. literalinclude:: People/Main.qml
    :lineno-start: 9
    :lines: 9-12