the code as follow doesn’t create the animation… But if the QPropertyAnimation is a new instance , then it can.. Why? what is the difference ? Thank you…
QRect orgRect = this->geometry();
QRect endRect = btExpand ? QRect(*ptNotePadPot, COLLAPSE_SIZE) :
QRect(*ptNotePadPot, EXPAND_SIZE);
/*
QPropertyAnimation* amt = new QPropertyAnimation(this, "geometry", this);
amt->setDuration(10000);
amt->setStartValue(orgRect);
amt->setEndValue(endRect);
amt->start();
*/
QPropertyAnimation amt(this, "geometry", this);
amt.setDuration(10000);
amt.setStartValue(orgRect);
amt.setEndValue(endRect);
amt.start();
After it starts, QProperyAnimation will create its own timer and run outside your main thread.
it will be destroyed after run pointer exit your function scope.
otherwise if u use
you will create one animation object in the memory to work and its pointed by amt pointer.
the pointer will be deleted after run pointer exit your function scope, not the QPropertyAnimation object.
but it will be a zombie in the memmory if you not delete it.
the best way is, use a class variable for QPropertyAnimation pointer. so you can delete the object in the pointer after program closed or when ever u want.
i hope it helps..
sory for my bad english.