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. [Solved] Change position of ListView
QtWS25 Last Chance

[Solved] Change position of ListView

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

    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
    0
    • M Offline
      M Offline
      mbrasser
      wrote on last edited by
      #2

      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
      0
      • B Offline
        B Offline
        bkamps
        wrote on last edited by
        #3

        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
        0
        • B Offline
          B Offline
          bkamps
          wrote on last edited by
          #4

          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
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved