本页内容

easingCurve QML Value Type

表示衰减曲线的数值。更多...

Import Statement: import QtQml
Since: Qt 6.11

详细描述

easingCurve 类型是一种带有属性的值,这些属性定义了一条easing curve :

  • enumeration type
  • real amplitude
  • real overshoot
  • real period
  • list<real> bezierCurve

这在使用FrameAnimation 进行自定义动画时非常有用,例如,或在任何需要沿给定曲线对值进行缓动处理的用例中。

要创建一个 `easingCurve ` 值,请指定一个缓动类型:

        readonly property easingCurve inQuartCurve: Easing.InQuart

以下示例与Easing 文档中描述的示例类似:

    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.
        readonly property easingCurve inQuartCurve: Easing.InQuart

        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 = inQuartCurve.valueForProgress(elapsed / duration)
        }
    }

由于 `easingCurve ` 是 `structured value ` 类型,因此可以使用 JavaScript 对象进行构造:

    readonly property easingCurve inElasticCurve: ({
        type: Easing.InElastic,
        amplitude: 4,
        period: 3
    })

在与 C++ 集成时,请注意:从 C++ 传递到 QML 的任何QEasingCurve 值都会自动转换为easingCurve 值。当easingCurve 值传递给 C++ 时,它会自动转换为QEasingCurve 值。

通过默认构造函数构造的easingCurve 等于new QtQml.easingCurve(QtQml.Easing.Linear) 。

另请参阅 QML 值类型。

© 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.