AnchorAnimation QML Type
为锚点值的更改添加动画效果。更多...
| Import Statement: | import QtQuick |
| Inherits: |
属性
- duration : int
- easing
- easing.amplitude : real
- easing.overshoot : real
- easing.period : real
- easing.type : enumeration
- targets : list<Item>
详细说明
AnchorAnimation 用于对锚点的变化进行动画处理。
在下面的代码片段中,我们对Rectangle 添加右锚点并进行动画效果:
import QtQuick
Item {
id: container
width: 200; height: 200
Rectangle {
id: myRect
width: 100; height: 100
color: "red"
}
states: State {
name: "reanchored"
AnchorChanges { target: myRect; anchors.right: container.right }
}
transitions: Transition {
// smoothly reanchor myRect and move into new position
AnchorAnimation { duration: 1000 }
}
Component.onCompleted: container.state = "reanchored"
}当在Transition 中使用AnchorAnimation时,它将对状态变化期间发生的任何AnchorChanges 进行动画处理。可以通过设置AnchorChanges.target 属性指定目标项来覆盖此行为。
注意:AnchorAnimation 仅可在Transition 中使用,且必须与 AnchorChange 配合使用。它不能用于行为(behaviors)和其他类型的动画。
另请参阅 《Qt Quick 中的动画与过渡》和《AnchorChanges 》。
属性文档
duration : int
该属性存储动画的持续时间,单位为毫秒。
默认值为 250。
easing group
指定动画所使用的缓动曲线
要指定缓动曲线,至少需要指定其类型。对于某些曲线,还可以指定振幅、周期和/或过冲。默认的缓动曲线为“线性”。
AnchorAnimation { easing.type: Easing.InOutQuad }有关不同类型缓动曲线的详细信息,请参阅PropertyAnimation::easing.type 文档。
targets : list<Item> [read-only]
需要重新锚定的项目。
如果未指定目标,所有AnchorChanges 都将通过AnchorAnimation 进行动画处理。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.