diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2023-03-17 13:53:51 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2023-03-21 11:27:17 +0100 |
commit | d32f8bfa1a807acb2967bbecaa661f0587890ae1 (patch) | |
tree | 4d855c407272aca7dad4cf3ff78c6451823a5fd9 /src/quick/doc/snippets | |
parent | 6b0744066b55cb4e4666ff0114252a6dd6be6e47 (diff) | |
download | qtdeclarative-d32f8bfa1a807acb2967bbecaa661f0587890ae1.tar.gz |
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 <mitch.curtis@qt.io>
Diffstat (limited to 'src/quick/doc/snippets')
4 files changed, 23 insertions, 8 deletions
diff --git a/src/quick/doc/snippets/qml/listview-decorations.qml b/src/quick/doc/snippets/qml/listview-decorations.qml index 3c5c3bcfc1..af8d2bdcb0 100644 --- a/src/quick/doc/snippets/qml/listview-decorations.qml +++ b/src/quick/doc/snippets/qml/listview-decorations.qml @@ -2,7 +2,7 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause //! [document] -import QtQuick 2.0 +import QtQuick //! [parent begin] Rectangle { @@ -24,7 +24,8 @@ ListModel { Component { id: nameDelegate Text { - text: name; + required property string name + text: name font.pixelSize: 24 } } 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] diff --git a/src/quick/doc/snippets/qml/repeaters/repeater.qml b/src/quick/doc/snippets/qml/repeaters/repeater.qml index cdb1f6f50a..bce6ec2bc9 100644 --- a/src/quick/doc/snippets/qml/repeaters/repeater.qml +++ b/src/quick/doc/snippets/qml/repeaters/repeater.qml @@ -24,7 +24,10 @@ Row { Column { Repeater { model: 10 - Text { text: "I'm item " + index } + Text { + required property int index + text: "I'm item " + index + } } } //! [index] @@ -33,7 +36,10 @@ Column { Column { Repeater { model: ["apples", "oranges", "pears"] - Text { text: "Data: " + modelData } + Text { + required property string modelData + text: "Data: " + modelData + } } } //! [modeldata] |