import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Layouts 1.13
Window {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
Item {
id: root
width: 320
height: 120
Rectangle {
id: rect
color: "green"
width: 120
height: 120
// 属性变化时动画
Behavior on x {
// 动画类型
NumberAnimation {
duration: 600
easing.type: Easing.OutBounce
}
}
MouseArea {
anchors.fill: parent
onClicked: {
if (rect.x == 0)
rect.x = 200
else
rect.x = 0
}
}
}
}
}
Qml Behavior属性变化时的默认动画
最新推荐文章于 2024-01-03 16:53:33 发布