posts - 319, comments - 22, trackbacks - 0, articles - 11
  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

PyQt 延迟触发槽函数 使用QTimer

Posted on 2011-05-01 13:21 RTY 阅读(2225) 评论(0)  编辑 收藏 引用 所属分类: QtPython

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


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理