AnchorAnimation QML Type

Animates changes in anchor values. More...

Import Statement: import QtQuick



Detailed Description

AnchorAnimation is used to animate an anchor change.

In the following snippet we animate the addition of a right anchor to a 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"

When an AnchorAnimation is used in a Transition, it will animate any AnchorChanges that have occurred during the state change. This can be overridden by setting a specific target item using the property.

Note: AnchorAnimation can only be used in a Transition and in conjunction with an AnchorChange. It cannot be used in behaviors and other types of animations.

See also Animation and Transitions in Qt Quick and AnchorChanges.

Property Documentation

duration : int

This property holds the duration of the animation, in milliseconds.

The default value is 250.

easing group

easing.amplitude : real

easing.overshoot : real

easing.period : real

easing.type : enumeration

Specifies the easing curve used for the animation

To specify an easing curve you need to specify at least the type. For some curves you can also specify amplitude, period and/or overshoot. The default easing curve is Linear.

AnchorAnimation { easing.type: Easing.InOutQuad }

See the PropertyAnimation::easing.type documentation for information about the different types of easing curves.

targets : list<Item> [read-only]

The items to reanchor.

If no targets are specified all AnchorChanges will be animated by the AnchorAnimation.

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