Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

ListView currentIndex



  • 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


  • Moderators

    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
      }
    }
    

Log in to reply