Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to clear pending signals in the queue?



  • Consider the following scenario: an object of class A is created in thread 1 and an object of class B is created in thread 2. Both A and B are QObjects. A connects to a signal emitted by B with QueuedConnection.

    Is there a way to stop thread 2, destroy object B and clear all the pending signals from B to prevent the handler in object A from being called after B is destroyed?

    There is QCoreApplication::removePostedEvents, but it is not clear how to use it.



  • No but you can use the B::destroyed signal to tell A when B is no more and let A skip the connected slot



  • No but you can use the B::destroyed signal to tell A when B is no more and let A skip the connected slot


Log in to reply