property int speedT: 0
property int speedA: HtCarStatus.speed*100
onSpeedAChanged: {
speedNumId.stop();
speedNumId.start();
}
SequentialAnimation{
id:speedNumId;
// NumberAnimation { target: root; property: "speedT";to:HtCarStatus.speed*100 ;duration: 100; easing.type: Easing.Linear}
NumberAnimation { target: root; property: "speedT";to:speedA ;duration: 100; easing.type: Easing.Linear}
Transition {
from: ""
to: "show"
SequentialAnimation{
// running: true //QML SequentialAnimation: setRunning() cannot be used on non-root animation nodes.
alwaysRunToEnd: true
ScriptAction{script: lefitBg.visible = false}
ParallelAnimation{
NumberAnimation {target: root;property: "v1";to:-180;duration: 1000;easing.type: Easing.InOutQuad}
NumberAnimation {target: root;property: "v2";to:180;duration: 1000;easing.type: Easing.InOutQuad}
NumberAnimation {target: root;property: "v3";to:-180;duration: 1000;easing.type: Easing.InOutQuad}
NumberAnimation {target: root;property: "v4";to:180;duration: 1000;easing.type: Easing.InOutQuad}
}
ScriptAction{script: lefitBg.visible = true}
ParallelAnimation{
SequentialAnimation{
NumberAnimation { target: root; property: "iolT";to:1000;duration: 500; easing.type: Easing.InOutQuad}
NumberAnimation { target: root; property: "iolT";to:0;duration: 500; easing.type: Easing.InOutQuad}
}
SequentialAnimation{
NumberAnimation { target: root; property: "speedT";to:19000;duration: 500; easing.type: Easing.InOutQuad}
NumberAnimation { target: root; property: "speedT";to:0;duration: 500; easing.type: Easing.InOutQuad}
}
}
},
Transition{
from: "show"
to:""
}
]speedA
property int speedA: HtCarStatus.speed*100
onSpeedAChanged: {
speedNumId.stop();
speedNumId.start();
}
SequentialAnimation{
id:speedNumId;
// NumberAnimation { target: root; property: "speedT";to:HtCarStatus.speed*100 ;duration: 100; easing.type: Easing.Linear}
NumberAnimation { target: root; property: "speedT";to:speedA ;duration: 100; easing.type: Easing.Linear}
}
Transition {
from: ""
to: "show"
SequentialAnimation{
// running: true //QML SequentialAnimation: setRunning() cannot be used on non-root animation nodes.
alwaysRunToEnd: true
ScriptAction{script: lefitBg.visible = false}
ParallelAnimation{
NumberAnimation {target: root;property: "v1";to:-180;duration: 1000;easing.type: Easing.InOutQuad}
NumberAnimation {target: root;property: "v2";to:180;duration: 1000;easing.type: Easing.InOutQuad}
NumberAnimation {target: root;property: "v3";to:-180;duration: 1000;easing.type: Easing.InOutQuad}
NumberAnimation {target: root;property: "v4";to:180;duration: 1000;easing.type: Easing.InOutQuad}
}
ScriptAction{script: lefitBg.visible = true}
ParallelAnimation{
SequentialAnimation{
NumberAnimation { target: root; property: "iolT";to:1000;duration: 500; easing.type: Easing.InOutQuad}
NumberAnimation { target: root; property: "iolT";to:0;duration: 500; easing.type: Easing.InOutQuad}
}
SequentialAnimation{
NumberAnimation { target: root; property: "speedT";to:19000;duration: 500; easing.type: Easing.InOutQuad}
NumberAnimation { target: root; property: "speedT";to:0;duration: 500; easing.type: Easing.InOutQuad}
}
}
ScriptAction{script: {HtCarStatus.activeSerial = true ;root.speedA = 100;}}
/*这里如果执行了root.speedA = 100;那么
property int speedA: HtCarStatus.speed*100
onSpeedAChanged: {
speedNumId.stop();
speedNumId.start();
}
speedA就不会响应HtCarStatus.speed*100这个值的变化,这样
onSpeedAChanged: {
speedNumId.stop();
speedNumId.start();
}就不会执行.
如果我们要在实例化对象中使用这个speedA这个变量,就不能在QML中对其赋值
否则控制权就在Javascript中,只能通过Javascript才能改动这个变量值*/
}},
Transition{
from: "show"
to:""
}
]speedA
本文探讨了QML中速度属性的动态更新方法及其动画效果实现,并深入分析了过渡动画和状态之间的交互逻辑,包括如何在不同状态下平滑地改变元素属性。
973

被折叠的 条评论
为什么被折叠?



