To make things clear, here is output from my test program (three threads: main, client, sender, neither client nor sender has event loop, client and sender live in main thread, socket lives in client thread):
Qt::AutoConnection (slot is executed in main thread):
"main, thread: b70a28e0"
server is listening
incoming connection
"client started, thread: b6e82bb0"
"sender started, thread: b6681bb0"
"sender emit signal, thread: b6681bb0"
"client slot, thread: b70a28e0"
QObject: Cannot create children
for a parent that is in a different thread.
"sender emit signal, thread: b6681bb0"
"client slot, thread: b70a28e0"
"main, thread: b70a28e0"
server is listening
incoming connection
"client started, thread: b6e82bb0"
"sender started, thread: b6681bb0"
"sender emit signal, thread: b6681bb0"
"client slot, thread: b70a28e0"
QObject: Cannot create children for a parent that is in a different thread.
"sender emit signal, thread: b6681bb0"
"client slot, thread: b70a28e0"
To copy to clipboard, switch view to plain text mode
Qt::DirectConnection (slot is executed in sender thread):
"main, thread: b71698e0"
server is listening
incoming connection
"client started, thread: b6f49bb0"
"sender started, thread: b6748bb0"
"sender emit signal, thread: b6748bb0"
"client slot, thread: b6748bb0"
QObject: Cannot create children
for a parent that is in a different thread.
"sender emit signal, thread: b6748bb0"
"client slot, thread: b6748bb0"
"main, thread: b71698e0"
server is listening
incoming connection
"client started, thread: b6f49bb0"
"sender started, thread: b6748bb0"
"sender emit signal, thread: b6748bb0"
"client slot, thread: b6748bb0"
QObject: Cannot create children for a parent that is in a different thread.
"sender emit signal, thread: b6748bb0"
"client slot, thread: b6748bb0"
To copy to clipboard, switch view to plain text mode
Qt::QueuedConnection (slot is executed in main thread):
"main, thread: b70df8e0"
server is listening
incoming connection
"client started, thread: b6ebfbb0"
"sender started, thread: b66bebb0"
"sender emit signal, thread: b66bebb0"
"client slot, thread: b70df8e0"
QObject: Cannot create children
for a parent that is in a different thread.
"sender emit signal, thread: b66bebb0"
"client slot, thread: b70df8e0"
"main, thread: b70df8e0"
server is listening
incoming connection
"client started, thread: b6ebfbb0"
"sender started, thread: b66bebb0"
"sender emit signal, thread: b66bebb0"
"client slot, thread: b70df8e0"
QObject: Cannot create children for a parent that is in a different thread.
"sender emit signal, thread: b66bebb0"
"client slot, thread: b70df8e0"
To copy to clipboard, switch view to plain text mode
Bookmarks