Cannot switch animation from one object to another. The identifier changes (it prints "world" in the log), but it does not transmit animation: hello is still blinking, and world static.
It only works correctly when a.restart() called. When there are no functions, just bindings, you can use onChanged and control how the animation stops (ends or pauses) if (running) { complete(); restart(); } if (running) { complete(); restart(); } if (running) { complete(); restart(); } .
import QtQuick 2.5 Column { ColorAnimation { id: a target: lab1 property: "color" running: true loops: Animation.Infinite duration: 500 from: "black" to: "red" } Text { id: lab1 text: "hello" MouseArea { anchors.fill: parent onClicked: { a.target = lab2 console.log("changed") console.log(a.target.text) } } } Text { id: lab2 text: "world" } }
source share