Update interface widgets or QML by QTimer
-
Hello everyone!
I have faced with the following question and cannot find any best practices guide about it. I deal with widgets and QML interfaces and use signal-slots mechanism to update labels, meters, buttons, etc in GUI. My programs can display different states of the hardware devices. In some cases there are a lot of updates with different frequencies (some meters is being updated faster e.g.). In this case interface starts to freezing (using signals-slot approach).
So my question is: is it a good practice to use special GUI timer (or multiple) to request backend for updates and redrawing the interface?
Can someone advice any good article about this question? -
Hi,
When you have frequencies input, what you would usually do is to cumulate the data and trigger updates less frequently e.g. by small or bigger batches.
It does not make sense to try to update your UI at 240 fps as you users won't see anything anyway.
-
@SGaist Yes, that's actually I have meant: a have a lot of data changes and there is no need to update interfaces that 240 fps. So as I understood from your message, updating and collecting data with some constant frequency (e.g. 25 fps) is a common used practice with Qt, isn't it?
Are there any built-in tools for it or it should be done manually? For example, adding Timer in any QML Component, connect its signals to function that update Components members with the updated data.
-
No, collect the data as fast as you can. You then have to find the "sweet spot" to trigger the update of your UI. You need some benchmarking for that.