Results 1 to 2 of 2

Thread: How to remove animations?

  1. #1
    Join Date
    Dec 2009
    Bratislava, Slovakia
    Qt products

    Default How to remove animations?

    I have a game with many animations. They are QPropertyAnimation applied to graphics items. I made a connect between signal finished() and my custom slot animationFinished(). At some point I want to cancel all animations and clean all graphics. I use this code to clean all:

    Qt Code:
    1. foreach(QGraphicsItem* git,graphicsView->scene()->items()){
    2. graphicsView->scene()->removeItem(git);
    3. }
    To copy to clipboard, switch view to plain text mode 

    The graphics view is clear after executing this code. But after some time (maybe when some animation finishes), the animationFinished() is executed. I assume my code removes the graphics items, but the property animations are still there. How can I remove them?

  2. #2
    Join Date
    Feb 2010
    Hyderabad, India
    Thanked 7 Times in 6 Posts
    Qt products

    Default Re: How to remove animations?

    When you start the animation, you can use the pass the argument QAbstractAnimation:eleteWhenStopped to the start function of the QPropertyAnimation.

    removeItem will not delete the graphicsItem. It will just remove it from the scene, hence its child, the QPropertyAnimation will not be deleted.
    To delete all the graphical items, use 'clear' slot of the graphicsscene.

Similar Threads

  1. remove flags?
    By konvex in forum Qt Programming
    Replies: 5
    Last Post: 18th March 2015, 02:26
  2. remove seperator
    By navi1084 in forum Qt Programming
    Replies: 0
    Last Post: 4th March 2009, 05:05
  3. remove of all QwtPlotCurves
    By gyre in forum Qwt
    Replies: 3
    Last Post: 21st December 2007, 07:58
  4. animations in Interview Delegates
    By eean in forum Qt Programming
    Replies: 5
    Last Post: 8th August 2007, 23:00

Tags for this Thread


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.