diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2024-04-22 14:15:37 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2024-04-23 14:01:19 +0200 |
commit | c0674262fd7e859a8002e6e850b6ec0a4162b456 (patch) | |
tree | c298748c9804b7657cf704ac951bccffafc8c3a3 /examples | |
parent | 9f09e1dda0f167432110a22db6f9a5accf800734 (diff) |
Documentation: Add QtQml.ListProperty
Pick-to: 6.7
Task-number: PYSIDE-2698
Change-Id: If9b9af49bb351fcb4e2355277ff84bd0936b5033
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/qml/tutorials/extending-qml-advanced/properties/doc/properties.rst | 10 | ||||
-rw-r--r-- | examples/qml/tutorials/extending-qml/chapter5-listproperties/doc/chapter5-listproperties.rst | 9 |
2 files changed, 10 insertions, 9 deletions
diff --git a/examples/qml/tutorials/extending-qml-advanced/properties/doc/properties.rst b/examples/qml/tutorials/extending-qml-advanced/properties/doc/properties.rst index 9337ad2ab..16924cdcd 100644 --- a/examples/qml/tutorials/extending-qml-advanced/properties/doc/properties.rst +++ b/examples/qml/tutorials/extending-qml-advanced/properties/doc/properties.rst @@ -75,11 +75,11 @@ 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 +people - are all of type :class:`~PySide6.QtQml.ListProperty`. +``ListProperty`` is a 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 ``ListProperty`` allows for "virtual lists" and other advanced scenarios. Running the Example diff --git a/examples/qml/tutorials/extending-qml/chapter5-listproperties/doc/chapter5-listproperties.rst b/examples/qml/tutorials/extending-qml/chapter5-listproperties/doc/chapter5-listproperties.rst index 90cb41107..a98f18c81 100644 --- a/examples/qml/tutorials/extending-qml/chapter5-listproperties/doc/chapter5-listproperties.rst +++ b/examples/qml/tutorials/extending-qml/chapter5-listproperties/doc/chapter5-listproperties.rst @@ -15,8 +15,9 @@ have a ``slices`` property that accepts a list of ``PieSlice`` items: :lines: 4-32 To do this, we replace the ``pieSlice`` property in ``PieChart`` with a -``slices`` property, declared as a class variable of the ``QQmlListProperty`` -type. The ``QQmlListProperty`` class enables the creation of list properties in +``slices`` property, declared as a class variable of the +:class:`~PySide6.QtQml.ListProperty` type. +The ``ListProperty`` class enables the creation of list properties in QML extensions. We replace the ``pieSlice()`` function with a ``slices()`` function that returns a list of slices, and add an internal ``appendSlice()`` function (discussed below). We also use a list to store the internal list of @@ -31,13 +32,13 @@ slices as ``_slices``: :lines: 75-79 Although the ``slices`` property does not have an associated setter, it is -still modifiable because of the way ``QQmlListProperty`` works. We indicate +still modifiable because of the way ``ListProperty`` works. We indicate that the internal ``PieChart.appendSlice()`` function is to be called whenever a request is made from QML to add items to the list. The ``appendSlice()`` function simply sets the parent item as before, and adds the new item to the ``_slices`` list. As you can see, the append function for -a ``QQmlListProperty`` is called with two arguments: the list property, and the +a ``ListProperty`` is called with two arguments: the list property, and the item that is to be appended. The ``PieSlice`` class has also been modified to include ``fromAngle`` and |