PathInterpolator QML Type

Legt fest, wie manuell entlang eines Pfades animiert werden soll. Mehr...

Import Statement: import QtQuick

Eigenschaften

Detaillierte Beschreibung

PathInterpolator liefert x, y und angle Informationen für einen bestimmten progress entlang eines Pfades.

Im folgenden Beispiel wird ein grünes Rechteck entlang eines Bezier-Pfades animiert.

import QtQuick

Rectangle {
    width: 400
    height: 400

    PathInterpolator {
        id: motionPath

        path: Path {
            startX: 0; startY: 0

            PathCubic {
                x: 350; y: 350

                control1X: 350; control1Y: 0
                control2X: 0; control2Y: 350
            }
        }

        NumberAnimation on progress { from: 0; to: 1; duration: 2000 }
    }

    Rectangle {
        width: 50; height: 50
        color: "green"

        //bind our attributes to follow the path as progress changes
        x: motionPath.x
        y: motionPath.y
        rotation: motionPath.angle
    }
}

Dokumentation der Eigenschaft

x : real [read-only]

y : real [read-only]

Diese Eigenschaft enthält die Position des Pfades bei progress.


angle : real [read-only]

Diese Eigenschaft enthält den Winkel der Bahntangente unter progress.

Die Winkel werden im Uhrzeigersinn angegeben, mit Null Grad auf der 3-Uhr-Position.


path : Path

Diese Eigenschaft enthält den zu interpolierenden Pfad.

Weitere Informationen zur Definition eines Pfades finden Sie in der Dokumentation Path.


progress : real

Diese Eigenschaft enthält den aktuellen Fortschritt entlang des Pfades.

Die typische Verwendung von PathInterpolator besteht darin, den Fortschritt zu setzen (oft über NumberAnimation) und die entsprechenden Werte für x, y und Winkel zu lesen (oft über Bindungen an diese Werte).

Der Fortschritt reicht von 0.0 bis 1.0.


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