Solved Creating custom animation by altering the size of a widget in loop.
-
I am trying to create a custom animation that would keep decreasing or increasing the size of widget in a loop with a custom delay function ( that delays the time for few seconds ) . but somehow its not working here is the code :
void delay(unsigned int sec){ clock_t goal = sec + clock(); while (goal > clock()); } void RamadanTimes::on_menucontroller_clicked(){ if (menubar->isVisible()){ for (int limit = 150;limit > 0;limit -= 10){ menubar->setGeometry(4,71,limit,440); menubar->show(); delay(1000); } menubar->hide(); }else{ for (int limit = 20;limit != 160;limit += 10 ){ menubar->setGeometry(4,71,limit,440); menubar->show(); delay(1000); } } menubar->setGeometry(4,71,160,440); // original size of menubar }
Thanks.
-
-
-
@SGaist Yeah okay how can i use QPropertyAnimation in my example ?
-
@Ahti Did you read the documentation?
There is an example doing exactly what you want to do:QPropertyAnimation *animation = new QPropertyAnimation(myWidget, "geometry"); animation->setDuration(10000); animation->setStartValue(QRect(0, 0, 100, 30)); animation->setEndValue(QRect(250, 250, 100, 30)); animation->start();
-
@jsulm yeah i did read the documentation but i quiet didn't get it. okay leave it i will look into it myself that way i would learn alot right ?
thanks for your help... God bless you brother :)
-
@Ahti Yes, learning by doing is a good idea :-)
-
Hi,
U have marked as solved, if u have any queries while doing , u can again ask in this topic.
have a nice day, cheers,Thanks,
-
@Pradeep-Kumar okay brother as you say :D
-