Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to move an object in a specified path...
Forum Updated to NodeBB v4.3 + New Features

How to move an object in a specified path...

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 4.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    endla.ravi
    wrote on last edited by
    #1

    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...

    1 Reply Last reply
    0
    • I Offline
      I Offline
      Immii
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • V Offline
        V Offline
        vcsala
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved