Easing QML Type (Singleton)
提供对缓动枚举和便捷 API 的访问。更多...
| Import Statement: | import QtQml |
| Since: | Qt 6.11 |
注意:此类型是 QML 单例。QML 引擎中仅有一个此类实例。
详细描述
Easing 单例提供对 `Easing ` 枚举的访问,该枚举通常由 `animations` 使用。它还提供 `valueForProgress ` 函数作为便捷 API:
Rectangle {
id: rect
width: 100
height: 100
anchors.centerIn: parent
color: "red"
opacity: 0
}
FrameAnimation {
id: frameAnimation
running: true
property real elapsed // In seconds.
readonly property real duration: 2 // Two seconds.
onTriggered: {
elapsed += frameTime
// Loop once we reach the duration.
if (elapsed > duration)
elapsed = 0
// Increase the opacity from 0 slowly at first, then quickly.
rect.opacity = Easing.valueForProgress(Easing.InQuart, elapsed / duration)
}
}该函数旨在提供一种便捷的方式,使值能够沿给定曲线进行缓动。若需更复杂的曲线,请使用easingCurve 值类型。
© 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.