×

Discussion Board

Results 1 to 15 of 15
  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    41

    How to move an object in a curve path

    i have a button that should moved from point1 to point2 where point1 and point2 are at the same y position but different x position , this is the code:


    animation = new QPropertyAnimation(ui->button, "geometry");
    animation->setDuration(time);
    animation->setStartValue(QRect(point1, size));
    animation->setEasingCurve(QEasingCurve::Linear);
    animation->setEndValue(QRect(point2,size));
    animation->start();
    my problem is that i want the moving path of the button from point1 to point2 is a semi circle or curve and not a line , how i can do that , plz help

  2. #2
    Nokia Developer Champion
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: How to move an object in a curve path

    Just a guess, but maybe you should use a different QEasingCurve value, like InCirc or OutCIrc.

  3. #3
    Registered User
    Join Date
    Nov 2010
    Posts
    41

    Re: How to move an object in a curve path

    thanks for ur reply,
    when changing the value of QEasingCurve to InCirc or OutCIrc the acceleration of moving the button is change but its still moving in a linear path .
    i want the button to move in a curve path , any help?

  4. #4
    Nokia Developer Champion
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: How to move an object in a curve path

    Subclass QButton and implement a "myProp" property (see http://doc.qt.nokia.com/4.6-snapshot...-overview.html for how to do this). Animate just an integer or float value that goes from start to end, then, in the logic for setMyProp, compute your widget coordinates from that value.

  5. #5
    Registered User
    Join Date
    Nov 2010
    Posts
    41

    Re: How to move an object in a curve path

    thanks again,
    i am using geometry property , after i set start and end value the button move from point1 to point2 but its move in a line path, but i want the movement to be in a cure not linear.i can make sequence animation in diagonal path but also its still in a linear path .

    in this function animation->setEndValue(QRect(point2,size)); i use QRec , can i use a curve or other object ?
    Last edited by wehbi; 2010-11-26 at 12:26.

  6. #6
    Nokia Developer Champion
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: How to move an object in a curve path

    Yes, I know what you're using (it's in the code you posted). You're using the wrong thing, however.

  7. #7
    Registered User
    Join Date
    Nov 2010
    Posts
    41

    Re: How to move an object in a curve path

    yes i know its not true code , but i am searching for another object as qcurve but i didnt found anything ... i am still searching may be i will find the solution

  8. #8
    Nokia Developer Champion
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: How to move an object in a curve path

    Please read what I posted. Subclass the object you want to move. Implement a property in the subclass that sets the object position (using the algorithm of your choice) based on a single value. Animate that property.

  9. #9
    Registered User
    Join Date
    Jul 2004
    Posts
    166

    Re: How to move an object in a curve path

    You might want to use QPainterPath, create curved painter path and then use painter path API to find position on painter path for some interval in percentage.

    I created following post that shows how this can be done.

    http://kunalmaemo.blogspot.com/2010/...rve-in-qt.html
    Last edited by kunal_the_one; 2010-12-01 at 09:56.
    http://kunalmaemo.blogspot.com/

  10. #10
    Registered User
    Join Date
    Nov 2010
    Posts
    41

    Re: How to move an object in a curve path

    thanks kunal , but i want to use the animation but just changing the path from linear to curve or circle .
    i think that i should create a new property for the button or something like that , any one have any idea ?

  11. #11
    Registered User
    Join Date
    Jul 2004
    Posts
    166

    Re: How to move an object in a curve path

    not sure how you can do that with QPropertyAnimation, but you can create your own Animation class derived from QAbstractAnimation and can use above logic to animate button in curve path.
    http://kunalmaemo.blogspot.com/

  12. #12
    Registered User
    Join Date
    Nov 2010
    Posts
    41

    Re: How to move an object in a curve path

    Quote Originally Posted by kunal_the_one View Post
    not sure how you can do that with QPropertyAnimation, but you can create your own Animation class derived from QAbstractAnimation and can use above logic to animate button in curve path.
    can you help me more about that , do u have any example or tutorial how i can do my own animation .
    thank you

  13. #13
    Registered User
    Join Date
    Jul 2004
    Posts
    166

    Re: How to move an object in a curve path

    I think you can use setKeyValueAt ( qreal step, const QVariant & value ) API of QPropertyAnimation, to set x position for different steps to move object on curve.
    http://kunalmaemo.blogspot.com/

  14. #14
    Registered User
    Join Date
    Nov 2010
    Posts
    41

    Re: How to move an object in a curve path

    thank u kunal , i used to setkeyvalue to move in a triangle path

  15. #15
    Registered User
    Join Date
    Jul 2004
    Posts
    166

    Re: How to move an object in a curve path

    welcome, I am glad that it helped.
    http://kunalmaemo.blogspot.com/

Similar Threads

  1. how to move a m3g object
    By ronykucse in forum Mobile Java Games
    Replies: 1
    Last Post: 2010-02-05, 09:51
  2. Learning Curve
    By kashifrazzaqui in forum Symbian
    Replies: 0
    Last Post: 2008-04-13, 20:46
  3. DRM 2.0: Rights Object path
    By sunilckore in forum Digital Rights Management & Content Downloading
    Replies: 8
    Last Post: 2007-07-04, 15:50
  4. Curve Lines
    By anxamobile in forum Mobile Java Media (Graphics & Sounds)
    Replies: 3
    Last Post: 2006-03-10, 02:00
  5. How to implement Bezier Curve ?
    By gauravgandhi80 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2004-06-22, 07:08

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •