Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to move an object in a specified path...
endla.ravi last edited by
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...
Immii last edited by
There are couple of examples available which does similar type animation, have you tried having look of those? at least two I remember "Easing Curve" and "path stroking" Hope this should give you enough insight how to do it.
vcsala last edited by
You have to use QPropertyAnimation class somehow like this snippet:
@ QPropertyAnimation *animation = new QPropertyAnimation(yourObject, "geometry");
animation->setStartValue(QRect(p1.x, p1.y, w, h));
animation->setEndValue(QRect(p2.x, p2.y, w, h));
where p1 and p2 is your points and w and h are the width and the height of the object you plan to move.