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: Use positionItemAtIndex when some items are invisible
Forum Updated to NodeBB v4.3 + New Features

ListView: Use positionItemAtIndex when some items are invisible

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 1 Posters 211 Views
  • 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.
  • M Offline
    M Offline
    maxwell31
    wrote on last edited by maxwell31
    #1

    Hi,

    I have a listview and a model. The model has some roles, which determine if a delegate should be shown, and I set the visible property of the delegate according to those roles. On clicked I want to use positionViewAtIndex to move the clicked item to the center of the list, but this is giving me some problems (empty lines before and after that item). I might not fully understand which index positionViewAtIndex wants. The actual index in the listview of visible items or the model index.

    The dummy code looks like this

    delegate: Item {
       onSpecialRoleChanged: {
            positionViewAtIndex(model.index)
       }
    }
    
    

    Maybe its also a bad idea to call this function inside the delegate.

    Btw, is there an easy way to get the visual index of an item in a listview (not the model index, as those things differ if we have invisible items)

    Thanks!

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

      Ok, the problem was that I seem to do the postionViewAtIndex at the wrong time. If the model gets updated, is there a signal i can catch after the listview updated itself?

      1 Reply Last reply
      0
      • M Offline
        M Offline
        maxwell31
        wrote on last edited by
        #3

        Hm, my question started with wrong assumptions, so I will close this question

        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