qml主要通过PropertyAnimation来实现动画,它通过改变属性,让属性从一个值到另一个值平滑过渡实现动画。经过各种变换和组合,可以实现很炫酷的效果。
4.1 动画基础
实现一个简单的颜色变化的动画:
Window {
width: 300
height: 250
visible: true
color: "gray"
title: qsTr("Hello World")
Rectangle {
id: rect1
width: 100; height: 100;
color: "green"
anchors.centerIn: parent
PropertyAnimation {
id: animColor
target: rect1
property: "color"
from: "green"
to: "red"
duration: 1000
}
MouseArea {
anchors.fill: parent
onClicked: {
animColor.start()
}
}
QML教程:动画实现与应用
订阅专栏 解锁全文
56

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



