Qt animation without Animation Framework
-
I need to update a QPixmap 1024x128 (math function paints a picture) 30...60 times a second and i don't want to use Animation Framework - i think that is overkill for this purpose. Frames cannot be pre-calculated and compiled to .gif .mp4 to play later, the "scene" is realtime and external data dependent.
Should i use QTimer with 30...60 ticks per second (TPS) and call update() in timer SLOT? But QTimer is not syncronized with actual screen updates and QTimer is inaccurate. My QTimer rate may be too low (not smooth motion) or too high (eat too much CPU) - how to find good one? My experiments showed that i need different QTimer intervals for my linux and windows test machines to get smooth update: linux: 30 TPS, windows: 50...60 TPS (i see rugged motion if i set 1000/30 msec).
Or maybe i mis-understood Animation Framework and actually it is very simple and appropriate for this task?
-
Actually for most cases the animation framework saves you more work than doing the task without. But sometimes a simple QTimer can be even less work. Depending on what you want to do. But the animation framework never felt like overkill. All you would need is probably QVariantAnimation/QPropertyAnimation class nothing more.
To come back to your problem. QTimer accuracy wont ever be that good on windows - or better said on non-real time systems. You may want to read "this thread":http://qt-project.org/forums/viewthread/5904.