Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. ListView currentIndex
Qt 6.11 is out! See what's new in the release blog

ListView currentIndex

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 340 Views 1 Watching
  • 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.
  • D Offline
    D Offline
    drd1988on
    wrote on last edited by
    #1

    In my QML view I have two tabs both tab uses same listview but on tab switch its model is changing

    i have to keep the current index of list view of each model on tab switch

    how can i achieve it

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2
      ListView {
        property int previousIndex: -1
      
        // No such signal in list view, of course, but you can use this
        // code in your tab component instead
        onTabSwitched: {
          var changeTo = previousIndex
          previousIndex = currentIndex
          currentIndex = changeTo
        }
      }
      

      (Z(:^

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved