Alex Rivera | Logout

How to call a function periodically in Qt?

Asked 2013-05-28T07:22:54.590
14

Is it possible to call a function periodically in C++ with Qt function ?
And how to stop the timed function after it is set to be called periodically ?

Edit
Report

1 Answer

1

You can use the QTimer class.

Just declare a QTimer with the desired time interval, wrap your function in a QObject as a slot, and connect the QTimer's timeout() signal to the slot you just declared.

Then, when the condition for stopping calling the function is met, just call QTimer::stop().

answered 2013-05-28T07:31:42.910

Your Answer