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 版起,该函数已被弃用。我们强烈建议不要在新代码中使用该函数。
请使用 chrono 重载。该静态函数在给定时间间隔后调用一个槽。
使用该函数非常方便,因为您无需使用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 毫秒)后自动终止。
receiver 是接收对象,member 是时隙。时间间隔为msec 毫秒。
注:此函数为可重入函数。
另请参阅 start()。
[static, deprecated in 6.8]
void QTimer::singleShot(int msec, Qt::TimerType timerType, const QObject *receiver, const char *member)
自 6.8 版起,该函数已被弃用。我们强烈建议不要在新代码中使用该函数。
这是一个重载函数。
请使用 chrono 重载函数。此静态函数在给定时间间隔后调用一个槽。
使用该函数非常方便,因为您无需使用timerEvent 或创建本地QTimer 对象。
receiver 是接收对象,member 是槽。时间间隔为msec 毫秒。timerType 会影响定时器的精度。
注:此函数为可重入函数。
另请参阅 start()。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.