Qt World Summit: Register Today!

[Solved] Change position of ListView

  • 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 }


  • 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 }


  • 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...


  • 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!

Log in to reply