Hi, I am hoping that someone could help me solve this seemingly simple problem:
How do I animate an item moving from one layout two another?

I have attached a small example of what I am trying to do, but even
more summarized the problem goes like this:

Row { id: top;    Box{id: box} }
Row { id: bottom; }
Button { onClicked: { box.parent = bottom; }

How do I animate this parentchange?

I have tried add/move-transitions on the rows, I have tried
ParentChange in states, ParentAnimations used on behaviors, nothing
seems to solve this problem. Any help would be greatly appreciated!

Thanks,

Harald Hvaal
[email protected]
import QtQuick 1.1

Rectangle {
    id: screen
    width: 500
    height: 400

    Row {
        id: upperLeft
        Rectangle {
            width: 100
            height: 100
            color: "green"
        }

        Rectangle {
            id: boxToAnimate
            width: 100
            height: 100
            color: "pink"
        }
    }

    Row {
        id: bottomRight
        anchors {
            bottom: parent.bottom
            right: parent.right
        }
        Rectangle {
            width: 100
            height: 100
            color: "blue"
        }
    }

    function animateSwitch() {
        if (boxToAnimate.parent == upperLeft)
            boxToAnimate.parent = bottomRight;
        else
            boxToAnimate.parent = upperLeft;
    }

    Rectangle {
        width: 200
        height: 50
        color: "red"
        anchors.right: parent.right
        Text {
            text: "Move box between layouts"
            anchors.centerIn: parent
        }
        MouseArea { anchors.fill: parent; onClicked: animateSwitch(); }
    }

}
_______________________________________________
Qt-qml mailing list
[email protected]
http://lists.qt.nokia.com/mailman/listinfo/qt-qml

Reply via email to