A utility class which provides timer signals and single-shot timers. More...
|WTimer (WObject *parent=0)|
|Construct a new timer with the given parent. |
|int||interval () const|
|Returns the interval (msec). |
|void||setInterval (int msec)|
|Sets the interval (msec). |
|bool||isActive () const|
|Returns if the timer is running. |
|bool||isSingleShot () const|
|Is this timer set to fire only once. |
|void||setSingleShot (bool singleShot)|
|Configures this timer to fire only once. |
|Starts the timer. |
|Stops the timer. |
|EventSignal< WMouseEvent > &||timeout ()|
|Signal emitted when the timer timeouts. |
|template<class T , class V >|
|static void||singleShot (int msec, T *receiver, void(V::*method)())|
|This static function calls a slot after a given time interval. |
|template<class F >|
|static void||singleShot (int msec, const F &f)|
|This static function calls a function after a given time interval. |
A utility class which provides timer signals and single-shot timers.
To use a timer, create a WTimer instance, set the timer interval using setInterval() and connect a slot to the timeout signal. Then, start the timer using start(). An active timer may be cancelled at any time using stop().
When connecting stateless slot implementations to the timeout signal, these stateless slot implementations will be used as for any other signal (when Ajax is available).
A WTimer is only usable inside of a Wt event loop. If you want to create a timer outside the Wt event loop, take a look at asio deadline_timer.
Timers are one way to provide updates of a web page without the user generating an event. Alternatively you may consider server-initiated updates, see WApplication::enableUpdates().
Configures this timer to fire only once.
A Timer is by default not single shot, and will fire continuously, until it is stopped.
This static function calls a slot after a given time interval.
For example, the following code will call this->doSome() after 2 seconds:
WTimer::singleShot(2000, this, &MyClass::doSome);
|const F &||f|
This static function calls a function after a given time interval.
This variant of the overloaded singleShot() method supports a template function object (which supports operator ()).