Qt Forum

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

    Drop Queued keyboard and mouse events

    QML and Qt Quick
    3
    5
    3225
    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.
    • B
      bundickt last edited by

      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 Reply Quote 0
      • F
        frankcyblogic.de last edited by

        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 Reply Quote 0
        • B
          bundickt last edited by

          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 Reply Quote 0
          • F
            frankcyblogic.de last edited by

            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 Reply Quote 0
            • G
              goetz last edited by

              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 Reply Quote 0
              • First post
                Last post