I am creating a C ++ application based on QML .
To make it simple:
In my main QML file, I have a (Rectangle) button that calls a JavaScript function (defined in an external JS file) when clicked:
// My JS file linked to the main QML window [...] function actionOnButtonClicked() { var x = 0; var y = 0; for(var i = 0; i < 3; i++) { createObject(x, y); x = x + 10; y = y + 10; } }
As you can see, in this function I call n (= 3 here) once another JS function to dynamically create several QML objects to add to the scene:
function createObject(xPosition, yPosition) { component = Qt.createComponent("Symbol.qml"); component.createObject(windowApp, {"x": xPosition, "y": yPosition}); }
It works great. But the created object (Symbol) appears in windowApp with the translation animation (about 1 second), and I would like to wait until the completion of the first animation of the object before creating the second ...
Since we cannot use the JavaScript function setTimeOut () in QML, I am wondering how I could achieve this. I do not see how I can use the QML Timer object or even PauseAnimation ...
Does anyone know how to add a delay between two JavaScript QML actions?
c ++ javascript qt qml qt-quick
Benoit
source share