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:
Code:
...
_groupH = new QParallelAnimationGroup();
connect(_groupH, SIGNAL(finished()), this, SLOT(loeschenAnimationenH()));
...
Code:
void Controller::erstelleAnimation(BasisAnzeigeElement* anz, const QPointF& endPos, QParallelAnimationgroup* group)
{
QPropertyAnimation* anim = new QPropertyAnimation(anz, "pos");
anim->setStartValue(anz->pos());
anim->setEndValue(endPos);
group->addAnimation(anim);
}
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.
Code:
loescheAnimationenH()
{
if(_groupH != NULL)
{
_groupH->clear();
}
}
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 :D
with best regards :)
nudels
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?
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? :)
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).