Making a ball move down on the click of a button
In this recipe, you will understand how a basic animation is applied on an object. This recipe will consist of a push button and a ball, and when the push button is pressed, the ball will start animating towards the ground.
How to do it...
To make this recipe, we will be making use of the QPropertyAnimation class. The setStartValue()Â and setEndValue()Â methods of the QPropertyAnimation class will be used to define the coordinates where the animation needs to start and end, respectively. The setDuration()Â method will be invoked to specify the delay in milliseconds between every animation move. The following is the step-by-step procedure to apply an animation:
- Create a new application based on the
Dialog without Buttonstemplate. - Drag and drop a
Labelwidget and onePush Buttonwidget onto the form. - Set the
textproperty of thePush Buttonwidget toMove Down. We assume that you have a ball image on your computer with the filenameÂcoloredball.jpg...