In questa pagina

AnchorAnimation QML Type

Anima le modifiche ai valori di ancoraggio. Altro...

Import Statement: import QtQuick
Inherits:

Animation

Proprietà

Descrizione dettagliata

AnchorAnimation viene utilizzato per animare la modifica di un'ancora.

Nel seguente frammento di codice animiamo l'aggiunta di un'ancora a destra a un Rectangle:

import QtQuick

Item {
    id: container
    width: 200; height: 200

    Rectangle {
        id: myRect
        width: 100; height: 100
        color: "red"
    }

    states: State {
        name: "reanchored"
        AnchorChanges { target: myRect; anchors.right: container.right }
    }

    transitions: Transition {
        // smoothly reanchor myRect and move into new position
        AnchorAnimation { duration: 1000 }
    }

    Component.onCompleted: container.state = "reanchored"
}

Quando si utilizza AnchorAnimation in un Transition, verrà animato qualsiasi evento AnchorChanges verificatosi durante il cambio di stato. È possibile sovrascrivere questo comportamento impostando un elemento di destinazione specifico tramite la proprietà AnchorChanges.target.

Nota: AnchorAnimation può essere utilizzata solo in un Transition e in combinazione con un AnchorChange. Non può essere utilizzata nei comportamenti (behaviors) né in altri tipi di animazioni.

Vedi anche Animazioni e transizioni in Qt Quick e AnchorChanges.

Documentazione delle proprietà

duration : int

Questa proprietà indica la durata dell'animazione, espressa in millisecondi.

Il valore predefinito è 250.

easing group

easing.amplitude : real

easing.overshoot : real

easing.period : real

easing.type : enumeration

Specifica la curva di accelerazione utilizzata per l'animazione

Per specificare una curva di accelerazione è necessario indicare almeno il tipo. Per alcune curve è possibile specificare anche l’ampiezza, il periodo e/o l’overshoot. La curva di accelerazione predefinita è Lineare.

AnchorAnimation { easing.type: Easing.InOutQuad }

Per informazioni sui diversi tipi di curve di accelerazione, consultare la documentazione su PropertyAnimation::easing.type.

targets : list<Item> [read-only]

Gli elementi da riancorare.

Se non vengono specificati obiettivi, tutti i AnchorChanges saranno animati dall'AnchorAnimation.

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