diff options
| author | Mate Barany <mate.barany@qt.io> | 2024-11-15 15:54:28 +0100 |
|---|---|---|
| committer | Mate Barany <mate.barany@qt.io> | 2024-11-18 22:15:20 +0100 |
| commit | 13da0d8133fefba2564dfa014020dd1c968bf0f5 (patch) | |
| tree | 1011cfac2b9933339ac91cc7a59f089193963d8b /src/quick/doc/snippets/qml | |
| parent | bad837c274be4e2d73636c46ce385f522b1c3d6f (diff) | |
Modify the Listview snippet to fix Unqualified access warnings
Probably has not been updated for a while now, copy pasting and running
the example leads to unqualified access warnings.
https://doc.qt.io/qt-6/qtquick-modelviewsdata-modelview.html
"In most cases you should use required properties to pass model data
into your delegates."
Fix the snippet by using required properties.
Pick-to: 6.8 6.5
Change-Id: I4a46f1ff29712238dd22bf4455a6674d8bdc0f49
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
Diffstat (limited to 'src/quick/doc/snippets/qml')
| -rw-r--r-- | src/quick/doc/snippets/qml/listview/listview.qml | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/quick/doc/snippets/qml/listview/listview.qml b/src/quick/doc/snippets/qml/listview/listview.qml index c8df8e727b..611f590542 100644 --- a/src/quick/doc/snippets/qml/listview/listview.qml +++ b/src/quick/doc/snippets/qml/listview/listview.qml @@ -13,6 +13,8 @@ ListView { model: ContactModel {} delegate: Text { + required property string name + required property string number text: name + ": " + number } } @@ -25,10 +27,13 @@ Rectangle { Component { id: contactDelegate Item { + id: myItem + required property string name + required property string number width: 180; height: 40 Column { - Text { text: '<b>Name:</b> ' + name } - Text { text: '<b>Number:</b> ' + number } + Text { text: '<b>Name:</b> ' + myItem.name } + Text { text: '<b>Number:</b> ' + myItem.number } } } } |
