ListView of qml doesn't support my NumberAnimation!!!

  • I want to locate the "currentItem" of the "listview" at the center of "view",so i use ListView's method "positionViewAtIndex()".And i also want the view change its "contentY" with an animation,but,the animation doesn't work!!!
    Can anybody tell me how to fix it?
    Here is my qml code:

    import QtQuick 2.4

    width: 250;height:300
    anchors.fill: parent
    anchors.margins: 3
    spacing: 4
    clip: true
    delegate: Rectangle{
    width: parent.width
    height: 30
    color:(index % 2 == 0)?"gray":"lightgray"
    anchors.centerIn: parent
    color: parent.ListView.isCurrentItem?"blue":"black"
    anchors.fill: parent
    onClicked: {
    lv.currentIndex=index; // to change the currentIndex,so that change the currentItem
    lv.positionViewAtIndex(index,ListView.Center); // to locate the currentItem at the center of the view

        Behavior on contentY {
            NumberAnimation{duration: 300} // I want to use animation to make it more beautiful


  • Anyone help?

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.