Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Solved Mystery property with ListViews

    QML and Qt Quick
    1
    2
    304
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      treaves last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • T
        treaves last edited by

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

        1 Reply Last reply Reply Quote 0
        • First post
          Last post