In Ubuntu SDK QML tutorial a simple currency converter is build. The complete QML source code can be found here. When working through the example I found the following snippet somewhat confusing, particularly line 92 where the index field is assigned to caller.currencyIndex
.
ListView {
clip: true
width: parent.width
height: parent.height - header.height
model: currencies
delegate: Standard {
objectName: "popoverCurrencySelector"
text: currency
onClicked: {
caller.currencyIndex = index // where does index come from?
caller.input.update()
hide()
}
}
}
I couldn't find any clue in the documentation where index
is defined. What it should contain is absolutely obvious, but where does it come from? If it is a property of the Standard
list view item it is nowhere documented.
index
is a property of the ListView delegate, not necessarily a ListItem. It represents the number of thecurrentItem
. From the docs: