Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QThread Event Queue

QThread Event Queue

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 1.4k Views
  • 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 Offline
    T Offline
    tyler1991
    wrote on last edited by
    #1

    Hi,

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

    kshegunovK 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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
      1
      • T Offline
        T Offline
        tyler1991
        wrote on last edited by
        #3

        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
        0
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #4

          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
          1
          • T tyler1991

            Hi,

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

            kshegunovK Offline
            kshegunovK Offline
            kshegunov
            Moderators
            wrote on last edited by
            #5
            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
            2

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved