0

For ListView in QML when currentIndex is changed programatically onMovementStarted and onMovementEnded are not called.

Button {
    onClicked: myListView.currentIndex = 2; // Any number within bounds
}

ListView {
    id: myListView
    orientation: ListView.Horizontal
    onMovementStarted: { /*...*/ }
    onMovementEnded { /*...*/ }
}

Now when the currentIndex is changed via the Button the onMovementStarted and onMovementEnded as well as onFlickStarted, onFlickEnded handlers are not called.

The model is a set of QML pages which are displayed using the delegate. Just like android screens.

But when the user flickers with the touch screen the handlers are called. How should I get handlers called when ListView is moved via Button click?

BaCaRoZzo
  • 7,502
  • 6
  • 51
  • 82
ak24
  • 11
  • 2
  • it's better to post an example, in qml you can emit manually signals, if you have a slot named onMovementStarted, then the signal is movementStarted() – Mido Oct 20 '15 at 17:29
  • You should also explain what you want to achieve. If the problem is related to animations, you can hook up to other properties, see for instance [this answer](http://stackoverflow.com/a/27189163/2538363). – BaCaRoZzo Oct 20 '15 at 20:47
  • Thanks for the link. In the link it is mentioned that when IncrementcurrentIndex() is called or currentIndex changes programmatically the OnMovementStarted slot is not called. so, movementStarted() signal is emitted on button click and timer is started for the same animation time. This resolved the issue, but it has to be done by UI developer which is an overhead. – ak24 Oct 21 '15 at 21:28
  • It's a solution, with a certain overhead, sure. Not that high actually. There could be other approaches. The point is, you should follow an approach like that, i.e. hook to other signals and do the stuff you want to do in the relative handler. Otherwise you can create a custom animation for the `ListView` associated with the button press. If you feel too unconfortable with either of them, open a bug report to ask for signal emition. – BaCaRoZzo Oct 22 '15 at 13:17

0 Answers0