Logo Search packages:      
Sourcecode: qt4-x11 version File versions

int QObject::startTimer ( int  interval  )  [inherited]

Starts a timer and returns a timer identifier, or returns zero if it could not start a timer.

A timer event will occur every interval milliseconds until killTimer() is called. If interval is 0, then the timer event occurs once every time there are no more window system events to process.

The virtual timerEvent() function is called with the QTimerEvent event parameter class when a timer event occurs. Reimplement this function to get timer events.

If multiple timers are running, the QTimerEvent::timerId() can be used to find out which timer was activated.


doc/src/snippets/code/src.corelib.kernel.qobject.cpp 8

Note that QTimer's accuracy depends on the underlying operating system and hardware. Most platforms support an accuracy of 20 milliseconds; some provide more. If Qt is unable to deliver the requested number of timer events, it will silently discard some.

The QTimer class provides a high-level programming interface with single-shot timers and timer signals instead of events. There is also a QBasicTimer class that is more lightweight than QTimer and less clumsy than using timer IDs directly.

See also:
timerEvent(), killTimer(), QTimer::singleShot()

Reimplemented in QTimer.

Definition at line 1497 of file qobject.cpp.

Referenced by Q3DateEdit::addNumber(), Q3TimeEdit::addNumber(), QTreeView::columnResized(), QTableView::columnResized(), QClipboard::event(), QLineEdit::event(), QWindowsStyle::eventFilter(), QMotifStyle::eventFilter(), QPlastiqueStyle::eventFilter(), QLineEdit::focusInEvent(), GLWidget::GLWidget(), QClipboard::mimeData(), Mouse::Mouse(), GLWidget::mouseReleaseEvent(), QMdiSubWindow::resizeEvent(), QTimeLine::resume(), QTableView::rowResized(), QTimeLine::setPaused(), QTimeLine::start(), QTimer::start(), QBasicTimer::start(), and QAbstractSpinBox::timerEvent().


    if (interval < 0) {
        qWarning("QObject::startTimer: QTimer cannot have a negative interval");
        return 0;

    d->pendTimer = true;                                // set timer flag

    if (!d->threadData->eventDispatcher) {
        qWarning("QObject::startTimer: QTimer can only be used with threads started with QThread");
        return 0;
    return d->threadData->eventDispatcher->registerTimer(interval, this);

Generated by  Doxygen 1.6.0   Back to index