The QTimer class provides timer signals and single-shot timers. More...
#include <qtimer.h>
Inherits QObject.
It uses timer events internally to provide a more versatile timer. QTimer is very easy to use, create a QTimer, call start() to start it and connect its timeout() to the appropriate slots, then when the time is up it will emit timeout().
Note that a QTimer object is destroyed automatically when its parent object is destroyed.
Example:
QTimer *timer = new QTimer( myObject ); timer->start( 2000, TRUE ); // 2 seconds single-shot connect( timer, SIGNAL(timeout()), myObject, SLOT(timerDone()) );
An alternative is to call QObject::startTimer() for your object and reimplement the QObject::timerEvent() event handler in your class (it must inherit QObject). The advantage is that you can have multiple running timers, each having a unique identifier. The disadvantage is that it does not support such high-level features as single-shot timers or signals.
Examples: aclock/aclock.cpp
Constructs a timer with a parent and a name.
Notice that the destructor of the parent object will destroy this timer object.
Destroys the timer.
Changes the timeout interval to msec milliseconds.
If the timer signal is pending, it will be stopped and restarted, otherwise it will be started.
See also: start() and isActive().
[virtual protected]
Handles timer events. Emits timeout() when a timer event is received.
Reimplemented from QObject.
Returns TRUE if the timer is running (pending), or FALSE is the timer is idle.
[static]
This static function calls a slot after a given time interval.
It is very convenient to use this function because you do not need to bother with a timerEvent or to create a local QTimer object.
Example:
#include <qapp.h> #include <qtimer.h> int main( int argc, char **argv ) { QApplication a( argc, argv ); QTimer::singleShot( 10*60*1000, &a, SLOT(quit()) ); ... // create your widgets return a.exec(); }
This sample program automatically terminates after 10 minutes (i.e. 600000 milliseconds).
Starts the timer with a msecs milliseconds timeout.
If sshot is TRUE, the timer will be activated only once, otherwise it will continue until it is stopped.
Any pending timer will be stopped.
See also: stop(), changeInterval() and isActive().
Examples: aclock/aclock.cpp
Stops the timer.
See also: start().
[signal]
This signal is emitted when the timer is activated.
This file is part of the Qt toolkit, copyright © 1995-96 Troll Tech, all rights reserved.
It was generated from the following files: