0
votes

I have created a GUI program with Qt which contains a few timers with short intervals. Another timer is also used to measure implemented timers timeout frequency.

Problem here is that updating GUI too often makes CPU give lesser attention to the timers and hence, timers don't behave as expected if their interval is short and GUI updating is frequent, unless somehow I hide the updating part of window or make updates less frequent.

Moving the timer based parts of the code into another thread is not that easy because timers are already implemented inside QWidget based objects which are not permitted to move into another thread.

My question is is this possible to lower window system events priority against QTimer? so maybe it would give more attention to timers timeout over GUI updates.

1
Did you look at this section of the docs? doc.qt.io/qt-5/qt.html#TimerType-enumMrEricSir
Yes @MrEricSir, but that can't solve the problem as it is not about precisionNixmd

1 Answers

4
votes

updating GUI too often makes CPU give lesser attention to the timers

That is literally nonsense.

The timer events run on the GUI thread, and the events are simply processed in order. There is no "priority", because while a GUI repaint or other event handling takes place, that thread is busy. Control must return to the event loop for the timer events to be processed. There is no preemption and there can be no preemption since preemption-free, run-to-completion handlers are the defining feature of event-driven GUIs. Everything would break if the timers could preempt the GUI code: you'd essentially include multi-threaded access to GUI objects!

You perhaps should be running those timers in a different thread, or reassess how you approach your problem.

Moving the timer based parts of the code into another thread is not that easy because timers are already implemented inside QWidget based objects

Well, that's where the design is wrong and you have to fix it.