Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    [Solved] Change position of ListView

    QML and Qt Quick
    2
    4
    2082
    Loading More Posts
    • 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.
    • B
      bkamps last edited by

      Hi,

      I want to move my listview (y-axis) but when I change Y position property or by using a PropertyAnimation it won't move!

      In the following code I use a "page" property to move the Listview to for example y: -320. In the console I see the y position has been calculated correctly (-320) but the thing won' move :). Also the onYChange handle is not called...

      What am I missing here?

      @
      ListView {
      property int page: 1
      id: listview
      spacing: 0
      y: 0
      width: 80
      height: 1280

      function calcY()
      {
      return (page*-320)
      }

      onPageChanged: listAnimation.start()

      PropertyAnimation { id: listAnimation; target: listview; properties: "y"; to: calcY(); duration: 100 }

      @

      1 Reply Last reply Reply Quote 0
      • M
        mbrasser last edited by

        Hi,

        I'd guess that onPageChanged is being called prior to the to binding being updated (i.e. the correct to value isn't set until after the animation is started, at which point it doesn't have any effect).

        You could try something like:

        @
        y: page * -320 //or (page-1) * -320?
        Behavior on y {
        NumberAnimation { duration: 100 }
        }
        @

        Regards,
        Michael

        1 Reply Last reply Reply Quote 0
        • B
          bkamps last edited by

          When I try this the listview still doesn't move.. I get the onPageChanged handler which tells me the page property has been changed (page 1, 2 etc).

          Btw: I don' prefer an animation, I just want to move the listview but when I set the y property it doesn' move.

          Is there maybe a problem I move the listview to a -y position? Is it a problem the listview should be "bounded" to some other element like a rectangle? I have tried this btw...

          Thanks!

          1 Reply Last reply Reply Quote 0
          • B
            bkamps last edited by

            I' sorry mbrasser but you were right! It does work! The problem was I added some qml code that anchors the listview to the parent (which has a smaller height).

            So my problem is solved, thanks!

            1 Reply Last reply Reply Quote 0
            • First post
              Last post