PDA

View Full Version : How to write a number animation on the mouse button press event in QML?



TheIndependentAquarius
11th December 2013, 09:00
import QtQuick 1.0

Rectangle
{
width: 100; height: 100
color: "red"

MouseArea
{
anchors.fill: parent

onPressed:
{
NumberAnimation
{
target: parent.x
to: 50;
duration: 1000
}
}
}
}


I expect this code to shift the x position of the rectangle on the button press event, but this does nothing.

Where am I going wrong?

TheIndependentAquarius
12th December 2013, 08:25
These threads solved my problem:
http://stackoverflow.com/questions/20514679/how-to-write-a-number-animation-on-the-mouse-button-press-event-in-qml
http://stackoverflow.com/questions/20516133/how-to-print-the-value-changed-through-the-numberanimation-on-console