2

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.

1 Answer 1

3

index is a property of the ListView delegate, not necessarily a ListItem. It represents the number of the currentItem. From the docs:

The index is exposed as an accessible index property. Properties of the model are also available depending upon the type of Data Model.

1
  • That was exactly the piece of documentation I was looking for! Would've never expected this to be a property of the delegate. Mar 3, 2014 at 8:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .