[Interest] Is it OK to emit from different thread?

Alexander Dyagilev alervdvcw at gmail.com
Fri Nov 30 19:53:19 CET 2018


Hello,

Let's suppose some QObject derived class belongs to thread A. It has 
some method, which emits some signal.

This method may be called from another thread B. Thus, signal will be 
issued for this object from the thread it does not belong to.

Is it OK?

source code (just in case):

class MyObject {
Q_OBJECT
signals:
void mySignal();
public:
void test();
}

void MyObject::test()
{
      emit mySignal();
}

// thread A:
...
auto obj = new MyObject();
...

// thread B:
...
obj->test();
...




More information about the Interest mailing list