From d32f8bfa1a807acb2967bbecaa661f0587890ae1 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 17 Mar 2023 13:53:51 +0100 Subject: Doc: Update documentation on model/view/delegates You should generally use required properties for all of this. Furthermore, correct some grammar problems, and synchronize the documentation to the examples it references. Remove the non-working ListElement in a C++-defined model. Pick-to: 6.5 Change-Id: I1be9b9997a86dc1028a71bdd5a94d6919c0f8a81 Reviewed-by: Mitch Curtis --- src/quick/doc/snippets/qml/qml-data-models/dynamic-listmodel.qml | 8 ++++++-- src/quick/doc/snippets/qml/qml-data-models/listelements.qml | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'src/quick/doc/snippets/qml/qml-data-models') diff --git a/src/quick/doc/snippets/qml/qml-data-models/dynamic-listmodel.qml b/src/quick/doc/snippets/qml/qml-data-models/dynamic-listmodel.qml index 4bf9fccb93..3c69012f67 100644 --- a/src/quick/doc/snippets/qml/qml-data-models/dynamic-listmodel.qml +++ b/src/quick/doc/snippets/qml/qml-data-models/dynamic-listmodel.qml @@ -15,8 +15,12 @@ Item { anchors.fill: parent model: fruitModel delegate: Row { - Text { text: "Fruit: " + name } - Text { text: "Cost: $" + cost } + id: delegate + required property string name + required property real cost + + Text { text: "Fruit: " + delegate.name } + Text { text: "Cost: $" + delegate.cost } } } //! [view] diff --git a/src/quick/doc/snippets/qml/qml-data-models/listelements.qml b/src/quick/doc/snippets/qml/qml-data-models/listelements.qml index bab4aec6a2..eecde1af0b 100644 --- a/src/quick/doc/snippets/qml/qml-data-models/listelements.qml +++ b/src/quick/doc/snippets/qml/qml-data-models/listelements.qml @@ -31,8 +31,12 @@ Item { anchors.fill: parent model: fruitModel delegate: Row { - Text { text: "Fruit: " + name } - Text { text: "Cost: $" + cost } + id: delegate + required property string name + required property real cost + + Text { text: "Fruit: " + delegate.name } + Text { text: "Cost: $" + delegate.cost } } } //! [view] -- cgit v1.2.3