Calling QML Listview signal handler explicitly from QML
-
I am using Listview(id : listview) in my application. I want to move the listview with up/down arrow buttons as well. So I created up/down buttons with in application to do the movement. When up/down button clicked, I am calling listview.onMovementStarted() and re positioning the listview by changing the contentY. Now the issue is when Listview is moved by flicking on the listview and then arrows are clicked immediately. So firstly onMovementStarted got called and then as listview.onMovementStarted() is called onMovementStarted got called again. Then onmovementEnded() has called though listview is still moving. Can somebody tell how to solve this or it is expected to behave like this?
Is it proper way to call listview.onMovementStarted() or listview.onMovementEnded() explicitly?
Thanks in advance for your reply.
-
@Yaswanth
You don't call another object's signal handler directly. If you want to send it a signal, you invoke the signal as a method, in this case
listview.movementStarted(). But you don't want to do that either. You can call the flick() method or animate the contentY property.If you want to prevent the listview from getting flicked while moving, just check the moving or flicking properties in onMovementStarted() and call cancelFlick().
-
@Yaswanth
It's in The QML Reference, under QML Object Attributes.http://doc.qt.io/qt-5/qtqml-syntax-objectattributes.html#signal-attributes
"To emit a signal, invoke it as a method. Any relevant signal handlers will be invoked when the signal is emitted, and handlers can use the defined signal argument names to access the respective arguments."