Results 1 to 4 of 4

Thread: QParallelAnimationGroup and QPropertyAnimation

  1. #1
    Join Date
    Oct 2011
    Posts
    9
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QParallelAnimationGroup and QPropertyAnimation

    Hello

    i have an Problem (maybe its an understanding problem)

    i want make an animation with some items. At program Start all Items where init, but only the first 3 should be visible.
    After i press a key, the next 3 items should be visible and go to an position.

    i have a class which have private QParallelAnimation and a function, where i create new Animation.
    in my Constructor of Controller i created the QParallelAnimationGroup and connected it with a slot of Controller-class:

    Qt Code:
    1. ...
    2. _groupH = new QParallelAnimationGroup();
    3. connect(_groupH, SIGNAL(finished()), this, SLOT(loeschenAnimationenH()));
    4. ...
    To copy to clipboard, switch view to plain text mode 


    Qt Code:
    1. void Controller::erstelleAnimation(BasisAnzeigeElement* anz, const QPointF& endPos, QParallelAnimationgroup* group)
    2. {
    3. QPropertyAnimation* anim = new QPropertyAnimation(anz, "pos");
    4. anim->setStartValue(anz->pos());
    5. anim->setEndValue(endPos);
    6. group->addAnimation(anim);
    7. }
    To copy to clipboard, switch view to plain text mode 


    and in the slot loescheAnimationenH() i clear the _groupH, because when i press a key, i emit a signal to the Controller and want to Display the next 3 Items.

    Qt Code:
    1. loescheAnimationenH()
    2. {
    3. if(_groupH != NULL)
    4. {
    5. _groupH->clear();
    6. }
    7. }
    To copy to clipboard, switch view to plain text mode 

    now my Problem is, when i make "anim = new QPropertyAnimation(anz, "pos")" i allways allocate memory, but i never give it free. Does _groupH->clear() deletes all animations and free the memory??

    and when yes, how can i fix it?
    i thougth to create a List "QList<QPropertyAnimation*> _animList;" and append allways the animation to it and in loescheAnimationH() i check if the _animList is empty, and when not, then i delete _animListe.at(i); and then make a _animListe.clear();

    or does i have an understanding problem?

    i hope somebodey understands me

    with best regards

    nudels

  2. #2
    Join Date
    Nov 2010
    Posts
    315
    Thanked 53 Times in 51 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QParallelAnimationGroup and QPropertyAnimation

    Documentations says that yes clear() should delete children animations and addAnimation should take ownership of animation.
    Why you have to delete/clear this animations?

  3. #3
    Join Date
    Oct 2011
    Posts
    9
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QParallelAnimationGroup and QPropertyAnimation

    hi and thanks for ur help

    because i allways want to set a new Item with a new PropertyAnimation with a new endPos and add this animation to the group.
    maybe ia make 3 PropertyAnimation private and change only the item and the pos. or how can i manage this?

  4. #4
    Join Date
    Nov 2010
    Posts
    315
    Thanked 53 Times in 51 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QParallelAnimationGroup and QPropertyAnimation

    Instead saying how you want do something you should describe what are you trying to achieve.

    Hint: note that you don't have to set starting point of animation. If you don't set that this value will be taken from animated property at the start of animation (but reversed animation will not work).

Similar Threads

  1. Problem with QParallelAnimationGroup
    By elmgreen in forum Qt Programming
    Replies: 0
    Last Post: 18th August 2011, 10:47
  2. QPropertyAnimation doesnt do anything
    By superpacko in forum Qt Programming
    Replies: 3
    Last Post: 20th July 2011, 16:04
  3. QPropertyAnimation dynamic end value is this possible?
    By GuusDavidson in forum Qt Programming
    Replies: 1
    Last Post: 11th March 2011, 12:09
  4. Replies: 0
    Last Post: 15th July 2010, 06:12
  5. Using QPropertyAnimation with QGraphicsPixmapItem
    By Luc4 in forum Qt Programming
    Replies: 8
    Last Post: 29th March 2010, 09:47

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.