Solved Repainting QWidget with QProperAnimation
-
I've updated previous comment. It paints only one animation anyway
-
Ok, im not sure what could be wrong.
Is it possible to upload project somewhere and post link here?
I want to run it.
Something is going on, i dont see.
Its clear the loop with 100 kills the event loop ( u need other design)
but both animations should run when there is only 1. -
-
@mrjj What's interesting, is that even if I try just to call this setChunk() method manually for two times in a row, without any loop, it still would paint only one animation.
-
ok. sounds. odd. i dont have time before tonight to see if i get same result :)
-
Solved it by creating QTimer) Thanks for your help!
-
@MadScientist92
Ok i was actually thinking about suggesting that to avoid the loop.Does it then run in parallel as you want?
-
Yes, it is now painting all the animations I want sequentially . Have to play around with the timing though, but that is still a huge step forward after a week of stupor)
-
@MadScientist92
Hi, from what I read sofar in this thread, I asume you want to draw a couple lines. In that way that only 1 line is drawn at a time? E.g: line 1 is drawn -> start drawing line2I would suggest the following:
Move all your animations into a list:
QList<QPropertyAnimation*> animationList; animationList.append(animation1); animationList.append(animation2); ... animationList.append(animationLast);
That make the following loop:
for(int i = 0; i < animationList.size()-1; i++){ connect(animationList[i], &QPropertyAnimation::finished, animationList[i+1], [=]{animationList[i+1]->start();}); }
This will automatically start the next animation, once the previousone is finsihed. No need for extra QTimer management,
If you want instead to draw multiple lines simultaneously, I would suggest looking into
QParallelAnimationGroup
-
I was attempting to draw equalizer for sound. Therefore, I needed to paint multiple 'states' of it. The problem was that only the last 'state' was drawn, and I wasn't getting a sequence of different animations.