QThread Event Queue



  • Hi,

    Is it possible to tell a QThread to drop the events stored on its event queue?


  • Lifetime Qt Champion

    Hi,

    AFAIK, no. Why would you need such a feature ?



  • 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.



  • 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


  • Qt Champions 2016

    QCoreApplication::removePostedEvents(nullptr, 0);
    

    But it comes with a disclaimer (look up the docs).


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.