Unsolved Calculate FPS in GUI Application
I was wondering if it somehow is possible to calculate the FPS in Qt. For it to work there has to be an event/a function that i can override that is called every frame. Is there something like that in Qt?
Thanks in advance
Unless it's some sort of animation a typical ui does not have a constant refresh rate. It only refreshes when something changes. It doesn't even have to update entire window, just the part that changed, so talking in terms of FPS when it comes to ui is rather meaningless. You could of course do a "game style" ui that redraws everything at a constant rate, but that would be incredibly wasteful.
What sort of app do you have in mind? Is it something like a full-window OpenGL, QML or a traditional widget based ui with panels, buttons and stuff?
Pl45m4 last edited by
@Chris-Kawa Thanks for the response. The applicaiton is a realtime simulation, but without openGL or QML (i.e. traditional) and i just wanted to display FPS to measure performance (usually it is a good indicator). Is there maybe another way to do this?
It depends on what it uses for that simulation.
FPS is just number of repaints per second so all you have to do is either count them and update every second or, if you need more frequency, you can measure time elapsed between draws and guesstimate by calculating 1/(frame delta).
If it's a widget you could count
paintEventper second like @Pl45m4 said.If it's a QOpenGLWidget you could similarly count
paintGLcalls per second. Hard to say without knowing more about what you use and how you repaint.