In questa pagina

easingCurve QML Value Type

Valore che rappresenta una curva di allentamento. Maggiori informazioni...

Import Statement: import QtQml
Since: Qt 6.11

Descrizione dettagliata

Il tipo ` easingCurve ` è un valore con attributi che definiscono un'easing curve:

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

È utile, ad esempio, quando si realizzano animazioni personalizzate con FrameAnimation, o in qualsiasi caso d'uso che richieda l'easing di un valore lungo una data curva.

Per creare un valore di tipo ` easingCurve `, assegnare un tipo di easing:

        readonly property easingCurve inQuartCurve: Easing.InQuart

L'esempio seguente è simile a quello descritto nella documentazione di 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)
        }
    }

Poiché ` easingCurve ` è un tipo ` structured value `, può essere costruito con un oggetto JavaScript:

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

Quando si integra con C++, si noti che qualsiasi valore ` QEasingCurve ` passato a QML da C++ viene automaticamente convertito in un valore ` easingCurve `. Quando un valore ` easingCurve ` viene passato a C++, viene automaticamente convertito in un valore ` QEasingCurve `.

Un easingCurve costruito con i valori predefiniti è uguale a new QtQml.easingCurve(QtQml.Easing.Linear).

Vedi anche Tipi di valore 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.