Sur cette page

easingCurve QML Value Type

Valeur représentant une courbe d'atténuation. En savoir plus...

Import Statement: import QtQml
Since: Qt 6.11

Description détaillée

Le type « easingCurve » est une valeur dotée d’attributs qui définissent une courbe d’ easing curve:

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

Elle est utile, par exemple, lors de la création d’animations personnalisées avec ` FrameAnimation`, ou dans tout cas d’utilisation nécessitant d’appliquer un effet d’accélération ou de décélération à une valeur le long d’une courbe donnée.

Pour créer une valeur « easingCurve », attribuez-lui un type d'accélération :

        readonly property easingCurve inQuartCurve: Easing.InQuart

L’exemple suivant est similaire à celui décrit dans la documentation d’ 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 étant un type « structured value », il peut être instancié à partir d’un objet JavaScript :

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

Lors de l’intégration avec C++, notez que toute valeur QEasingCurve transmise à QML depuis C++ est automatiquement convertie en une valeur easingCurve. Lorsqu’une valeur easingCurve est transmise à C++, elle est automatiquement convertie en une valeur QEasingCurve.

Un objet « easingCurve » construit par défaut est égal à « new QtQml.easingCurve(QtQml.Easing.Linear) ».

Voir également Types de valeurs 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.