QThread Event Queue
Unsolved
General and Desktop
-
wrote on 13 Mar 2017, 18:33 last edited by
Hi,
Is it possible to tell a QThread to drop the events stored on its event queue?
-
Hi,
AFAIK, no. Why would you need such a feature ?
-
wrote on 15 Mar 2017, 16:10 last edited by
I want to issue a reset where I clear the queues in my program. However, if the qthread event loop still has events to be processed, they will be processed even after the reset. I want to prevent this from happening.
-
wrote on 15 Mar 2017, 17:01 last edited by
First thing first: If your program needs such a feature I'm not convinced your design is optimal.
Having said that you could try call
moveToThread(nullptr)
on the worker object inside the thread to achieve what you are asking. I'm not saying it will work, I'm just saying it's the only thing I can think of -
QCoreApplication::removePostedEvents(nullptr, 0);
But it comes with a disclaimer (look up the docs).
1/5