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 contentY problem

ListView contentY problem

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

    Hi

    In my QML app I have a ListView populated from a model. Each delegate in the ListView is a button which moves you to a new screen. I save the ListView's contentY property so that when the user moves back, he/she can be at the same point in the list as when he left it.

    The problem is that, if this point is some way down the list, there is a pause to move there, because the ListView instantiates each delegate until that point is reached.

    In a list with many delegates this causes a noticeable slow-down.

    I guess this happens because the system doesn't know what height each delegate is, so it has to instantiate each one to figure out which delegate is at the given Y co-ordinate.

    Is there a way round this? e.g. to specify a fixed height for each delegate? Or to give delegates a way to return their height without instantiating themselves (Cocoa Touch's ListView equivalent, I forget what it is called, offers both of these).

    Thanks

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      I thought there was something like an "averageItemHeight" property (or something along those lines), but I can not find it anymore, so I might have been mistaken on that. Does it help if you set the contentHeight property explicitly to the height of your delegate * the number of items in your list?

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

        Hi,

        You should be able to use ListView's "positionViewAtIndex()":http://doc.qt.nokia.com/4.7/qml-listview.html#positionViewAtIndex-method function for this.

        Regards,
        Michael

        Edit: fixed URL (Andre)

        1 Reply Last reply
        0
        • S Offline
          S Offline
          shullw
          wrote on last edited by
          #4

          I also have listViews that I use in an app I am developing. It also goes to a different page when an item is clicked. The strange thing is, when I go back, it is already in the place I left it, without using any other programming like Y position or what not. My question is are you making it load the listview over and over again. When I move away from my list I just make that list view visible: false. For me that keeps the list where it was and when I go back the visible: true just makes it seen again. If there is no need to repopulate the list then this should solve your problem.

          A QML Purest Point of View!

          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