QML之Repeater
-
Delegates are exposed to a read-only index property that indicates the index of the delegate within the repeater. For example, the following Text delegate displays the index of each repeated item
Column { Repeater { model: 10 Text { text: "I'm item " + index } } } // I'm item 0 I'm item 1 I'm item 2 I'm item 3
-
If the model is a string list or object list, the delegate is also exposed to a read-only modelData property that holds the string or object data.
Column { Repeater { model: ["apples", "oranges", "pears"] Text { text: "Data: " + modelData } } } // Data apples Data oranges Data pears