6
QT QTimer 的单次延迟触发静态函数演示
source link: https://ii74.com/post/17.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
QT QTimer 的单次延迟触发静态函数演示
哎哎5年前 (2016-09-22)C++962
#include <QApplication>
#include <QTimer>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QTimer::singleShot(600000, &app, SLOT(quit()));
...
return app.exec();
}
在QTimer的帮助手册中查询到了,如下函数
void QTimer::singleShot ( int msec, QObject * receiver, const char * member ) [static]
介绍是 ,可以根据设置,进行单次的延迟触发。
只需要一句话,即可延迟触发某函数。
main.c
QTimer::singleShot(1000,&w,SLOT(runDebug()));
mainwindow.cpp
void MainWindow::runDebug()
{
qDebug()<<QString::fromLocal8Bit("续一秒是坠吼的");
}
运行结果 +1s;
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK