- Qt 6.11
- Qt Core
- C++ Classes
- QTimer
- Qt 6.11.1 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.

Starting from Qt 6.10, setting a negative interval will result in a run-time warning and the value being reset to 1ms. Before Qt 6.10 a Qt Timer would let you set a negative interval but behave in surprising ways (for example stop the timer if it was running or not start it at all).

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.

Starting from Qt 6.10, setting a negative interval will result in a run-time warning and the value being reset to 1ms. Before Qt 6.10 a Qt Timer would let you set a negative interval but behave in surprising ways (for example stop the timer if it was running or not start it at all).

This is an overloaded function.

Note: This function is reentrant.

See also start().