PDA

View Full Version : QML ListView change CurrentIndex - Transition



Gihu
28th June 2012, 15:31
Hi,

I'm using Qt 5 Alpha, QtQuick 2 and want to define Transitions when I switch the CurrentIndex (not the highlight) of a ListView.
The delegate of the ListView contains a Img and I want to scale it while changing.

Is this possible?

Thank You.

Le_B
28th June 2012, 16:32
not tested qt5 enough but in qtquick 1.1
- the element of your model should have an "active" property
- the delegate has a state "active" when active == true
- the transition of the state will do the animation (you can set it reversible)
- onCurrentIndexChanged of your listview: active the current item in the model (that must deactivate old value)

Added after 4 minutes:

a simplier way :
create a : property QtObject currObj for your listview
create a function active(newObj) that will set the standart state of the curObj, set the "active" state of newObj and then copy newObj to curObj
in the onclicked of your mouseArea of the delegate just call active(<id_of_delegate>)