0
votes

I have just started learning QML and was trying to implement a simple table via a ListView (using this SO article as a guide).

I wanted to make one of the columns editable so I used TextField in place of Label for that column. Where I came unstuck was finding how to write the updated value back into the model. I found the setProperty method on the model but it was not at all clear how to access the index of the delegate's 'current item' to provide as the first argument of the method call.

After trying and failing to use currentIndex, eventually I discovered that I could in fact use index but I don't understand how I should have known this and where it is documented. I ask this question because I suspect there are some basic concepts I am missing that should have made this obvious.

1

1 Answers

1
votes

It's mentioned in the documentation for ListView::delegate:

The delegate provides a template defining each item instantiated by the view. The index is exposed as an accessible index property. Properties of the model are also available depending upon the type of Data Model.

It's also mentioned on this page, though that's a little harder to find.