How to move an object in a specified path...
-
Hi..
how can i move an object(may be a dotted point) on a line.
I have seen the colliding mice example,but could not understand the code.
Suppose i have
QLine *line= new QLine(p1,p2); //where p1 and p2 are QPoint objects.
Now is there any way to move my object on that line?..If yes how?
Thanking you in advance...
-
You have to use QPropertyAnimation class somehow like this snippet:
@ QPropertyAnimation *animation = new QPropertyAnimation(yourObject, "geometry");
animation->setDuration(10000);
animation->setStartValue(QRect(p1.x, p1.y, w, h));
animation->setEndValue(QRect(p2.x, p2.y, w, h));animation->start();@
where p1 and p2 is your points and w and h are the width and the height of the object you plan to move.