if you have 4 properties and each one has a Behavior block (that lets you animate if the corresponding property is changed ) if you change 4 properties then the animation will be parallel by default, but is it possible to make the Behavior blocks execute in sequence?
import QtQuick
import QtQuick.Controls
ApplicationWindow {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
Rectangle {
id: root
width:196
height:196
color:"lightgray"
Rectangle {
id: box
width:48
height:48
x:10
y:10
color: "red"
rotation:0
MouseArea {
id:d
anchors.fill: parent
onClicked: {
parent.x= parent.x==10 ? root.width - parent.width -10 : 10
parent.y= parent.y==10 ? root.height - parent.height -10 : 10
parent.rotation= parent.rotation==360 ? 0 : 360
parent.color=parent.color=="#ff0000" ? "teal": "red"
}
}
Behavior on rotation {
id:d1
RotationAnimation {
duration: 500
}
}
Behavior on x {
id:d2
NumberAnimation {
duration: 500
}
}
Behavior on y {
id:d3
NumberAnimation {
duration: 500
}
}
Behavior on color {
id:d4
ColorAnimation{
duration:500
}
}
}
}
}
I tried to `onClicked:{ ... d1.start() d2.start() ...
` but it doesn't make sense for Qml
Following this guide (Using Qt Quick Behaviors with States) I've used
StateandTransitioninstead ofBehavior. You can simply replace theSequentialAnimationwithParallelAnimationto get your old behavior back.This paragraph from the guide advises to use
TransitionandStateto avoid unwanted behavior.NumberAnimationcould also be combined to move theRectangleinxandyat the same time.to