Unsolved Signal/Slot syncing between two Qthread
-
Hi all,
In my software, i'm using the
QThread::wait(ms)
method to wait a slot result of another QThread.A summary of my project is the following.
-The Main thread is MainWindow class basic :public QMainWindow
-The Second thread is created with the following method and this object is created withcomm_modules class : public QObject
The second thread or objet is created in the main thread constructor.
Second Thread constructor :
comm_modules(){ _thread = new QThread; moveToThread(_thread); _thread->start(); myInit(); }
I was tried the connect method with argument
Qt::BlockingQueuedConnection
but i have obtain a deadlock !Have you an simple idea to "wait" the finish signal of a slot ? Of an another slot
Thanks a lot
-
Have you an simple idea to "wait" the finish signal of a slot ?
QEventLoop loop; QObject::connect(myobject,&MyObject::FinishedSignal,&loop,&QEventLoop::quit); loop.exec();
-
@VRonin Good idea, but how to do with two different thread ?
-
Hi,
Since you only have two threads why not just use a counter that you decrement when the slot is called and when at zero, execute the rest of your initialization ?
-
I have just put this argument in 5nd argument of connect method.
Qt::BlockingQueuedConnection