Is the call to connect () thread safe in Qt?

I have two QObject

A

and B

living in separate QThread

s. A

will issue a signal, and B

- the corresponding slot. I want to use connect()

to connect a signal A

to a slot B

.

So the question is, is the connect()

call thread safe ? Does it matter in which of the two threads the connection occurs?

+3


source to share


1 answer


Yes, QObject :: connect () is a thread-safe method:

Note. All functions in this class are reentrant, but connect (), connect (), disconnect (), and disconnect () are also thread safe.



It doesn't matter which thread you are connecting from. But you have to take care of using auto connection

(default connection), unique connection

or queuing up between your objects. And you have to run event loops on both of your threads.

Also I highly recommend that you check the following articles: first , second .

+2


source







All Articles