PyQt 延迟触发槽函数 使用QTimer

1、示例代码

1         QtCore.QTimer.singleShot(self.delaySpinBox.value()  *   1000 ,
2                 self.shootScreen)

2、关于QTimer.singleShot 的用法

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

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, SLOT(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 setSingleShot() and start().

你可能感兴趣的:(PyQt 延迟触发槽函数 使用QTimer)