Results 1 to 7 of 7

Thread: QTimeLine

  1. #1
    Join Date
    Nov 2007
    Posts
    291
    Thanks
    85
    Thanked 1 Time in 1 Post

    Default QTimeLine

    hi
    i have a QGraphicsItemAnimation object which after certain period requires change of one QTimeLine(which is already set) to another QTimeLine .
    if i do this then the program crashes .
    is there any way to change the animations timeline .

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTimeLine

    How exactly do you change the time line objects? Post some code, if possible.

  3. #3
    Join Date
    Nov 2007
    Posts
    291
    Thanks
    85
    Thanked 1 Time in 1 Post

    Default Re: QTimeLine

    hi
    i want to reset(not restarting ) the timeline.

    this code crashes
    Qt Code:
    1. timelineW = new QTimeLine(5000);
    2. ann->setTimeLine(timelineW);
    3.  
    4. tim = new QTimeLine(1000);
    5. ann->setTimeLine(tim); //resetting to new timeline
    6.  
    7. ann->setPosAt(0, QPointF(800, 10));
    8. ann->setPosAt(1, QPointF(220, 10));
    9. timelineW->start();
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTimeLine

    Beacause the item deletes the previous time line(if any) when you set a new one:
    Qt Code:
    1. void QGraphicsItemAnimation::setTimeLine(QTimeLine *timeLine)
    2. {
    3. if (d->timeLine == timeLine)
    4. return;
    5. if (d->timeLine)
    6. delete d->timeLine;
    7. if (!timeLine)
    8. return;
    9. d->timeLine = timeLine;
    10. connect(timeLine, SIGNAL(valueChanged(qreal)), this, SLOT(setStep(qreal)));
    11. }
    To copy to clipboard, switch view to plain text mode 
    Therefore timelineW is invalid after you set tim as the new time line.
    You should call tim->start().

  5. The following user says thank you to marcel for this useful post:

    babu198649 (31st January 2008)

  6. #5
    Join Date
    Nov 2007
    Posts
    291
    Thanks
    85
    Thanked 1 Time in 1 Post

    Default Re: QTimeLine

    thanks for pasting the perfect code .

  7. #6
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTimeLine

    If you want to reset the time line, why don't you use QTimeLine::setCurrentTime(0)?

  8. #7
    Join Date
    Nov 2007
    Posts
    291
    Thanks
    85
    Thanked 1 Time in 1 Post

    Default Re: QTimeLine

    thanks.
    If you want to reset the time line, why don't you use QTimeLine::setCurrentTime(0)?
    the animation object should synchronize with the other items timer.

Similar Threads

  1. QGraphicsItemAnimation and QTimeLine
    By babu198649 in forum Newbie
    Replies: 13
    Last Post: 31st December 2007, 11:34

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.