QEventloop块边界

时间:2017-09-27 12:44:55

标签: qt qeventloop

我声明了QEventloop类属性:

   class myClass: public QObject
    {
        Q_OBJECT
        public:
            explicit QZXingFilterRunnable(QZXingFilter * filter)
    // ...
        private:
            //  ...
            QEventLoop myEvt;
    };

然后在一个类方法中,我想为特定代码段设置事件循环,我不明白QEventloop如何知道它的边界,这是代码:

myClass::myMethod(void*)
    : QObject(nullptr)

{
// Code Block1 ....
// ....
// ...code Block2
// ...
// Code Block to be looped by QEventloop
    // this is the block I want in loop
    timer.setSingleShot(true);
    timer.setInterval(100);
    QObject::connect(&timer, SIGNAL(timeout()), &something, SLOT(cancel()));
    QObject::connect(&timer, SIGNAL(timeout()),  &myEvt, SLOT(quit()));
    QObject::connect(&watcher, SIGNAL(finished()), &myEvt, SLOT(quit()));
     QtConcurrent::run(this,&myClass::myMethod,*param);
    timer.start(); 
    myEvt.exec();  // How do MyEvt know which code block is to be in loop ?
    //

0 个答案:

没有答案