ListView, positionViewAtIndex and smooth scrolling
-
Hi all,
I have a ListView with some elements. I can manually scroll the list to see all element.
Now I'd like to autoscroll the list and I'm using this code:@
...
Timer {
interval: 1000; running: true; repeat: true
onTriggered: scorriLista()
}
property int indexAttualeLista: 0
function scorriLista()
{
list.positionViewAtIndex(indexAttualeLista, ListView.Center)
indexAttualeLista = indexAttualeLista + 1
if(indexAttualeLista >= list.count)
indexAttualeLista = 0
}ListView {
id: list
anchors.fill: parent
model: model
delegate: MyDelegate {}
}
@It works but I'd like to have a smooth scroll to the next visible element.
How can I obtain the smooth effect when scrolling ?
-
I solved by replacing:
@
list.positionViewAtIndex(indexAttualeLista, ListView.Center)
@with:
@
list.currentIndex = indexAttualeLista
@and by adding:
@
highlightMoveSpeed: 70
@in the ListView to slow down the movement speed.