title: QML: wait until animations finished
body: <p>I am trying to make visible animations sequential. I have a javascript function, which call myModel.move() two times. I have a GridView to show myModel and I have "Behavior on x" animation, thus I can visualy see the movements. But, both movement animatons runs in paralell (the small delay between them is not noticeable).</p>
  
  <p>My idea was to add a counter of how many animations was started and how many of them already finished. Something like this;</p>
  
  <pre><code>Behavior on x {
      NumberAnimation {
          id: animationX;
          duration: 500;
          onRunningChanged: {
              if (animationX.running) {
                  console.log("Animation start");
                  myModel.busy = myModel.busy + 1
              } else {
                  console.log("Animation stop");
                  myModel.busy = myModel.busy - 1
              }
          }
      }
  }
  </code></pre>
  
  <p>This works as expected. Then, I add a loop to my javascript function to wait until all the animations finished.</p>
  
  <pre><code>ListModel {
      id: myModel
      property int busy: 0
      function doSomething() {
          myModel.move(...)
          while (myModel.busy) {}
          myModel.move(...)
      }
  }
  </code></pre>
  
  <p>Here is the problem. I can see that after the first move() all neccessary animations started, but nothing can be seen and none of the animation finished. I have some kind of a deadlock. How to solve this?</p>