Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Drop Queued keyboard and mouse events
QtWS25 Last Chance

Drop Queued keyboard and mouse events

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 3 Posters 3.6k 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.
  • B Offline
    B Offline
    bundickt
    wrote on last edited by
    #1

    Is there a way to turn off queueing of keyboard and mouse events?

    What I want:
    If a keyboard event comes in before the previous event has been processed it does't get added the the event queue; it will get dropped.

    What happens:
    In my event queue thread (main application thread) I can make calls that can block for up to 2 seconds. While the thread is blocking, if the user presses some keys they will be queued up and processed after the block is done. The problem I am facing is sometimes the users key events will cause more 2 second blocking calls and cause even more queueing. This will make my GUI pretty much stop and is not my desired affect. I don't mind if the GUI freezes for 2 seconds here or there, but it's when the gui freezes for minutes it's a problem.

    1 Reply Last reply
    0
    • frankcyblogic.deF Offline
      frankcyblogic.deF Offline
      frankcyblogic.de
      wrote on last edited by
      #2

      Blocking calls in the GUI threads sounds quite evil. Why not put those into a background thread? Make it signal the foreground thread once something is done. Simply use Qt's thread-aware signal-slot mechanism.

      Hope, you don't mind for my short recipe;)

      1 Reply Last reply
      0
      • B Offline
        B Offline
        bundickt
        wrote on last edited by
        #3

        Even if i remove the non blocking calls from the main event thread I still need a way to get rid of queue events. It still causes undesired affects. Is this possible? and if it is how?

        1 Reply Last reply
        0
        • frankcyblogic.deF Offline
          frankcyblogic.deF Offline
          frankcyblogic.de
          wrote on last edited by
          #4

          I don't think your architecture is all right. Anyways, there was something to eat queued events... QCoreApplication::processEvents(). Maybe, you want to give it a try. Of course you can't do it directly in QML.

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on last edited by
            #5

            I would just introduce a boolean sentinel:

            • Set it to true before you do your work.
            • Check it in the slots connected to your UI elements. If it's true do nothing, if it's false start the workload.
            • After your work is done reset it to false.

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply
            0

            • Login

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