Calculating animation time Qt
First of, I'm fairly new to Qt. I did look for the answer but didn't find anything similar to my problem. I am using a timer that timeouts every 50ms and a
to animate a circling rectangle(my own class that paints the rectangle and changes its coordinates every time advance is called) until it does a full circle on a QGraphicsView.
Is there any way to measure the time it takes the animation to finish? Basically I'm pushing the button, the animation starts, the rectangle finishes the circle and I need to output the time it took it to do so. I know I can use QTime to calculate the time but I don't understand where the to put it because it is using the signal-slot mechanism and a timer. Thanks.
If I understood your question correctly and you are only trying to measure the time it took for you to draw the animation, and not the actual time it took to draw the animation, then your task is quite simple.
If the timer times out every 50 ms, then if you count the number of steps it took for you to draw the animations, and multiply that by 50ms, you have the complete time.
If your advance() function steps every time by a fixed amount of radians, then you don't need to calculate anything. You know beforehand how much time will it take. It can be easily calculated as such:
t = StepTime * (2 * pi) / StepAngle
if step angle is in radians, or alternatively
t = StepTime * (360)/StepAngle
if step angle is in degrees.