Mystery property with ListViews



  • I'm learning QML. I'm playing with an application that uses a ListView, and I'm using a delegate and a model. I was figuring out how to get something done, and in doing so, I came across this code:

    list_view1.currentIndex = index
    

    This code resides in the delegate. It sets the currentIndex property of ListModel instance to the current items index.

    They question is, where is the property index coming from?

    Originally my delegate was just a separate QML file with an Item{}, and this code (in context of course) worked. It set the index to the current delegate. But I can find no index property in Item. And I've read the documentation for ListView, and it mentions nothing like this either.

    Any pointers appreciated.



  • I finally found a reference to the index 'role' in http://doc.qt.io/qt-5/qtquick-modelviewsdata-modelview.html .


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.