[Interest] Behavior on parent with ParentAnimation

Dmitry Volosnykh dmitry.volosnykh at gmail.com
Wed Dec 24 11:11:27 CET 2014


Documentation mentions only usage with states, transitions and
ParentChange. Is it possible to use ParentAnimation inside Behavior or even
as a standalone animation that is launched manually?

Here's modified example from ParentAnimation's web page:

import QtQuick 2.0

Item {
    objectName: "root"
    width: 200; height: 100

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


    Rectangle {
        id: blueRect
        objectName: "blueRect"
        x: parent === redRect ? 10 : redRect.width
        y: parent === redRect ? 10 : 0
        width: 50; height: 50
        color: "blue"

        Behavior on parent {
            ParentAnimation {
                NumberAnimation { properties: "x,y"; duration: 1000 }
            }
        }

        onParentChanged: console.log("parent:", parent.objectName)

        MouseArea { anchors.fill: parent; onClicked: blueRect.parent =
redRect }
    }
}

Blue rectangle instantly jumps inside the red one instead of moving
smoothly.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20141224/2e463015/attachment.html>


More information about the Interest mailing list