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
Item{
width: 250;height:300
ListView{
id:lv
anchors.fill: parent
anchors.margins: 3
spacing: 4
clip: true
delegate: Rectangle{
width: parent.width
height: 30
color:(index % 2 == 0)?"gray":"lightgray"
Text{
anchors.centerIn: parent
text:index+1
color: parent.ListView.isCurrentItem?"blue":"black"
}
MouseArea{
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
}
}
}
model:40Behavior on contentY { NumberAnimation{duration: 300} // I want to use animation to make it more beautiful } }
}
-
Anyone help?