NumberAnimation QML Type
动画 qreal 类型值的变化。更多
Import Statement: | import QtQuick |
Inherits: | |
Inherited By: |
属性
详细说明
NumberAnimation 是一个专门的PropertyAnimation ,用于定义数值变化时应用的动画。
以下是应用于Rectangle 的x
属性的 NumberAnimation,作为属性值源。它在 1000 毫秒内将x
的值从当前值动画为 50:
import QtQuick Rectangle { width: 100; height: 100 color: "red" NumberAnimation on x { to: 50; duration: 1000 } }
与其他动画类型一样,NumberAnimation 可以多种方式应用,包括过渡、行为和属性值源。 Qt Quick 文档 中的动画和过渡显示了多种创建动画的方法。
请注意,如果正在跟踪的数字值发生不规则变化,NumberAnimation 可能无法顺利制作动画。如果是这种情况,请使用SmoothedAnimation 代替。
另请参阅 Qt Quick和Qt Quick 示例 - 动画中的动画和过渡。
属性文档
from : real |
该属性用于保存动画的起始值。
例如,在x
值达到 100 时才会应用以下动画:
Item { states: [ // ... ] transitions: Transition { NumberAnimation { properties: "x"; from: 100; duration: 200 } } }
如果NumberAnimation 定义在Transition 或Behavior 中,则该值默认为Transition 的起始状态中定义的值,或Behavior 被触发时该属性的当前值。
另请参阅 Qt Quick 中的动画和过渡。
to : real |
该属性保存动画的结束值。
如果NumberAnimation 定义在Transition 或Behavior 中,则该值默认为Transition 的结束状态中定义的值,或触发Behavior 的属性变化值。
另请参阅 Qt Quick 中的动画和过渡。
© 2025 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.