PDA

View Full Version : QTimer at 50Hz on Linux - High CPU Usage



Elisabetta
14th June 2018, 07:35
Hello,
I am using QT 5.8

On Windows I have no ploblems.
On Fedora 25 Using a qTimer set at 50 hz, the CPU usage rises to 90%.
If I reduce the frequency of the qTimer the CPU usage decreases considerably.




QTimer* m_timer; // in file .h

// in file .cpp

m_timer= new QTimer();
int interval = (1 / 50) * 1000;

m_timer->start(interval);

connect(m_timer SIGNAL(timeout()),
this, SLOT(slotRead()));



Can you give me some suggestions?

Thanks in advance!
Best Regards!

Ginsengelf
14th June 2018, 08:06
int interval = (1 / 50) * 1000;


Hi, "interval" here becomes zero because 1/50 is done using integers. This is probably not what you want (or not what you actually do...).

Ginsengelf