In my application, we have a simple connection between signal slot.
connect(&A, SIGNAL(signal(myObject)), &B, SLOT(slot(myObject));
This connection, unfortunately, will lead to a recursion. Then we changed it into
connect(&A, SIGNAL(signal(myObject)), &B, SLOT(slot(myObject)), Qt::QueuedConnection);
and it does not work anymore. The slot is never called.
I tried changing myObject
for a QString
and it works as expected. So the problem is something in myObject
that Qt does not like so much.
I checked Class Qt.ConnectionType, Signals & Slots and QObject doc, looking for Qt::QueuedConnection
but I have not found a clarification for my situation.
Some notes about my code:
The
myObject
is destructed just after the emission of the signal. But it should not be a problem, a copy could have been made (as I suppose is for QString, that has not this problem, I mean, even if I pass a temporaryQString
and destroy it right after the emission of the signal, the slot is anyway called as expected)myObject
is NOT aQObject
, and noone of its members are aQObject
(if it can have some influence)myObject
CAN be copiedMy application is SINGLE thread
myObject
has NO default constructor (but I do not think it should influence it, since a copy could be made)I am using Qt 5.7
Does anyone have some clarification for this problem?
Actually, the documentation of Qt::QueuedConnection
seems not so detailed, see the links I posted above. Do you have some more useful link?
Register your myObject by:
where MyObject is the class name. doc
Between, Qt::QueuedConnection is for connection over threads, your are using threads?