- Qt 6.9
- Qt Core
- C++ Classes
- QTimer
- Qt 6.9.3 Reference Documentation

# Obsolete Members for QTimer

The following members of class QTimer are deprecated. They are provided to keep old source code working. We strongly advise against using them in new code.

## Static Public Members

`(deprecated in 6.8)` void | singleShot(int msec, const QObject *receiver, const char *member)
`(deprecated in 6.8)` void | singleShot(int msec, Qt::TimerType timerType, const QObject *receiver, const char *member)

## Member Function Documentation

### `[static, deprecated in 6.8]` void QTimer::singleShot(int msec, const QObject *receiver, const char *member)

This function is deprecated since 6.8. We strongly advise against using it in new code.

Use the chrono overloads. 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 create a local QTimer object.

Example:

     #include <QApplication>
     #include <QTimer>

     int main(int argc, char *argv[])
     {
         QApplication app(argc, argv);
         QTimer::singleShot(600000, &app, QCoreApplication::quit);
         ...
         return app.exec();
     }

This sample program automatically terminates after 10 minutes (600,000 milliseconds).

The receiver is the receiving object and the member is the slot. The time interval is msec milliseconds.

Note: This function is reentrant.

See also start().

### `[static, deprecated in 6.8]` void QTimer::singleShot(int msec, Qt::TimerType timerType, const QObject *receiver, const char *member)

This function is deprecated since 6.8. We strongly advise against using it in new code.

Use the chrono overloads. 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 create a local QTimer object.

The receiver is the receiving object and the member is the slot. The time interval is msec milliseconds. The timerType affects the accuracy of the timer.

This is an overloaded function.

Note: This function is reentrant.

See also start().