[Interest] Destroy all queued events on QObject::disconnect?

Nikos Chantziaras realnc at gmail.com
Fri Jan 18 18:41:48 CET 2019

On 18/01/2019 11:06, Alexander Dyagilev wrote:
> The previous problem I recently wrote about was caused by me thinking 
> that QObject::disconnect also destroys all queued events caused by this 
> connection. This was obviously wrong.
> But, I still want Qt to behave so. Is there a way to achieve such behavior?

You can explicitly specify that the connections should be 
Qt::BlockingQueuedConnection rather than using the default (which is 
Qt::AutoConnection, meaning the connections are queued connections for 
objects in different threads.)

Heed the warning about deadlocks:


Another solution would be to use Qt::DirectConnection, but then you need 
to make the slot(s) thread-safe and be careful not to call functions 
that are not supposed to be called from a non-UI thread or functions 
that are not thread safe.

All in all though, you current design sound wonky.

More information about the Interest mailing list