NumberAnimation QML Type
以动画形式展示 qreal 类型值的变化。更多...
| Import Statement: | import QtQuick |
| Inherits: | |
| Inherited By: |
属性
详细说明
NumberAnimation 是一种专门的PropertyAnimation ,用于定义在数值发生变化时应用的动画效果。
以下是一个应用于Rectangle 的x 属性的NumberAnimation,用作属性值来源。它将x 的值从当前值动画过渡到50,耗时1000毫秒:
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 的property change的值。
另请参阅 Qt Quick 中的“动画与过渡”。
© 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.