[Qt-qml] QML JS Weirdness

Adriano Rezende adriano.rezende at openbossa.org
Fri Dec 3 16:02:28 CET 2010


On Thu, Dec 2, 2010 at 10:48 PM, Jason H <scorp1us at yahoo.com> wrote:
> Addendum.
>
> No joy. None of the animations start. I have declared the bool as
>  property bool active: false
> and set the
>  running: root.active
> then in my start() function:
>  root.active = true
>
> Conceptually, it should work.

Try the code below (mouse press will trigger the animation):

Item {
    id: root
    width: 400
    height: 400

    property bool active : mouseArea.pressed

    MouseArea {
        id: mouseArea
        anchors.fill: parent
    }

    Rectangle {
        id: rect
        color: "red"
        width: 100
        height: 100
    }

    PropertyAnimation {
        running: root.active
        target: rect
        property: "x"
        from: 0
        to: 100
        duration: 400
        loops: Animation.Infinite
    }
}

Br,
Adriano




More information about the Qt-qml mailing list