PDA

View Full Version : Run QML files one after another in sequence



mvbhavsar
27th October 2013, 18:41
Hi All,

My question is on QML. I have lets say 5 .qml files in same directory and each file is having some item and animation attached to that item.

One.qml
Two.qml
Three.qml
Four.qml
Five.qml

Now I want all these 5 .qml files should be executed in sequence i.e. it will start with One.qml and once all its animation is completed it will be removed and Two.qml will start executing its animation and this will continue till Five.qml's execution is completed.
I want to know how this can be achieved?


Regards

Manish

d_stranz
27th October 2013, 19:13
QML files are descriptions of user interfaces and and actions that execute when certain events or signals are received by the elements inside them. They aren't "programs", they don't "execute". They get loaded into memory, parsed, and sit there, waiting for one of the events or signals to occur, and then they react to it.

Animations run when their "running" property is set to "true" or their "start()" method is invoked. One way to cause a series of animations to run in sequence is to connect animation 2 with the "onStopped" slot of animation 1, something like this:



// One.qml:

Animation {
id: one

onStopped: two.running = true
}


// Two.qml
Animation {
id: two

onStopped: three.running = true
}

// etc.


You could also use the Animation::start() method. Setting the "running" property to "true" is equivalent to calling start().

The code above isn't valid QML - you can't use the Animation object stand-alone; you have to use one of the derived types (NumberAnimation, PropertyAnimation, etc.)

anda_skoa
27th October 2013, 21:47
One approach for a sequence of scenes would be to have a main file that uses a loader to load the invidual scenes.
Each scene would also emit a signal once its last animation is done.
The main file would connect to the loader item's signal and change the loader source to the next file in the sequence.

Cheers,
_

d_stranz
27th October 2013, 23:26
One approach for a sequence of scenes would be to have a main file that uses a loader to load the invidual scenes.
Each scene would also emit a signal once its last animation is done.
The main file would connect to the loader item's signal and change the loader source to the next file in the sequence.


Yes, I thought of this as another way to do the same thing. In this case, the main file needs to know about all of the items in the sequence; in my case, each item only needs to know what comes next. Either solution will do what is needed.

mvbhavsar
28th October 2013, 05:00
Thanks d_stranz and anda_skoa.

Yes, I know that these qml files aren't executable programs but just want to run one after another as a sequence of event. Both the methods stands valid for me as I will be knowing which are qml files are there and which to run next. Both the methods are providing me the solution which I am looking for.

Thanks a lot for quick help.


Regards

Manish