Results 1 to 2 of 2

Thread: Eventfilter delay

  1. #1
    Join Date
    Dec 2016
    Posts
    37
    Qt products
    Qt5
    Platforms
    Windows

    Default Eventfilter delay

    I've got an app with multiple tabs. I install an event filter on qApp to handle keystrokes as I would like to process certain keystrokes as shortcuts to do certain things.

    For the most part it works, except when it doesn't.

    Sometimes the keystrokes just don't get processed. After a while I noticed that when the keystrokes did not work, if I clicked around on various tabs, then after a couple of clicks of the mouse the keystrokes just start working.

    What's going on and how do I fix it?

    n

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Eventfilter delay

    If you're installing an event filter on the main application instance, then you should be seeing all the events from the main thread all the time. Have you read the docs on events and filters, especially the parts about returning true or false from your event filter?

    I for one would probably never install an event filter on the application instance. There is too much danger of unintended consequences - things stop working or act strangely because there is some circumstance you haven't checked for in your handler and thus the wrong action occurs. I would probably install an event filter on an object instance closer to where the action takes place, like on the QTabWidget or the QMainWindow.

    There might be other ways to implement this same functionality without using event filters, such as by installing a QAction with the keystroke shortcut on the tab or main window widget. See QWidget::addAction() and Qt::ShortcutContext.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. EventFilter problem
    By aruval3 in forum Qt Programming
    Replies: 10
    Last Post: 17th November 2011, 21:22
  2. Yet another eventFilter question
    By ls4f in forum Qt Programming
    Replies: 8
    Last Post: 14th September 2011, 13:50
  3. Autorepeat within eventfilter
    By Patrick_Bao in forum Qt Programming
    Replies: 0
    Last Post: 1st December 2010, 07:37
  4. sceneEventFilter or eventFilter
    By zgulser in forum Qt Programming
    Replies: 7
    Last Post: 4th May 2009, 07:50
  5. EventFilter and MouseMoveEvent
    By mickey in forum Qt Programming
    Replies: 10
    Last Post: 28th January 2006, 09:53

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.