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 and onCurrentIndexChanged
Forum Updated to NodeBB v4.3 + New Features

ListView and onCurrentIndexChanged

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 8.4k 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.
  • 2 Offline
    2 Offline
    2beers
    wrote on last edited by
    #1

    Hi everyone. I have a ListView

    @ ListView{
    id:someListView
    anchors.fill: parent

        currentIndex: 0
        onCurrentIndexChanged: root.currentIndex = currentIndex
    
        orientation: Qt.Horizontal
        boundsBehavior: Flickable.DragOverBounds
        model: someModel
    
        highlightRangeMode: ListView.StrictlyEnforceRange
        snapMode: ListView.SnapOneItem
        highlightFollowsCurrentItem:true
    
    }@
    

    the index is changed when the second item is at half of the ListView screen. Can I make it change only when the second item is entirely visible to the screen??

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MartinJ
      wrote on last edited by
      #2

      You could only set root.currentIndex once the view has stopped moving:

      @ onCurrentIndexChanged: if (!moving) root.currentIndex = currentIndex
      onMovingChanged: if (!moving) root.currentIndex = currentIndex@

      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