Pregunta

How to get it to work anchors animation, like described here:

import QtQuick 2.0

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

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

    Behavior on anchors.right {
        AnchorAnimation { duration: 2000 }
    }

    Component.onCompleted: {
        myRect.anchors.right = container.right
    }
}

What am I doing wrong? There is no proper animation on changing anchors.

Also, if you can, provide some examples on this theme.

UPD: Provided simpler example.

¿Fue útil?

Solución

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.

from AnchorAnimation documentation. There you can also find an example how to use states to do AnchorAnimations.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top