Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved QThread Event Queue

    General and Desktop
    4
    5
    1134
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      tyler1991 last edited by

      Hi,

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

      kshegunov 1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

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

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 1
        • T
          tyler1991 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.

          1 Reply Last reply Reply Quote 0
          • V
            VRonin 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

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            1 Reply Last reply Reply Quote 1
            • kshegunov
              kshegunov Moderators @tyler1991 last edited by

              QCoreApplication::removePostedEvents(nullptr, 0);
              

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

              Read and abide by the Qt Code of Conduct

              1 Reply Last reply Reply Quote 2
              • First post
                Last post