Obsolete Members for QTimer

以下成员源于类 QTimer 被弃用。 提供它们是为使旧源代码能继续工作。强烈建议不要在新代码中使用它们。

静态公共成员

(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 )

成员函数文档编制

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

此函数从 6.8 起弃用。强烈建议在新代码中不要使用它。

Use the chrono overloads. This static function calls a slot after a given time interval.

使用此函数非常方便,因为不需要麻烦采用 timerEvent 或创建本地 QTimer 对象。

范例:

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

此范例程序在 10 分钟 (600,000 毫秒) 后自动终止。

The receiver 是接收对象而 member 是槽。时间间隔为 msec 毫秒。

从 Qt 6.10 开始,设置负间隔会导致运行时警告,且值被重置为 1ms。在 Qt 6.10 之前,Qt 计时器允许设置负间隔,但行为方式出人意料 (例如:停止计时器,若在运行或根本未启动)。

注意: 此函数是 可重入 .

另请参阅 start ().

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

此函数从 6.8 起弃用。强烈建议在新代码中不要使用它。

Use the chrono overloads. This static function calls a slot after a given time interval.

使用此函数非常方便,因为不需要麻烦采用 timerEvent 或创建本地 QTimer 对象。

The receiver 是接收对象而 member 是槽。时间间隔为 msec 毫秒。 timerType 影响计时器精度。

从 Qt 6.10 开始,设置负间隔会导致运行时警告,且值被重置为 1ms。在 Qt 6.10 之前,Qt 计时器允许设置负间隔,但行为方式出人意料 (例如:停止计时器,若在运行或根本未启动)。

这是重载函数。

注意: 此函数是 可重入 .

另请参阅 start ().