Quantcast
Channel: QtWebEngine
Viewing all articles
Browse latest Browse all 13965

Qt::DirectConnection querries for multi threaded application?

$
0
0
Hi, I have some querries regarding how SIGNAL SLOT behave in multi threaded use case. Consider the following connection: connect(parentObj, SIGNAL(sig1()), workerObj, SLOT(slot1()), Qt::DirectConnection);     emit sig1();     qDebug("SIGNAL1 emitted!"); //workerObj is moved to different QThread. Some querries: 1. Is it guaranteed that qDebug() will be executed only after slot1() is executed? 2. In which thread is slot1 executed, parentObj thread or workerObj thread? 3. Instead of above code if I use workerObj->slot1() i.e. through parentObj thread is it correct/legal? 4. Declaration of a SIGNAL requires a return type. So if the connection is Direct, is it guaranteed that the return value from the emit statement will be the same value as returned by the connected SLOT? //parentObj class signals: bool sig2();   //workerObj class slots: bool slot2();   connect(parentObj, SIGNAL(sig2(bool)), workerObj, SLOT(slot2(bool)), Qt::DirectConnection); bool result = emit sig2();//is this legal?

Viewing all articles
Browse latest Browse all 13965

Trending Articles