Results 1 to 4 of 4

Thread: How to prevent shortcut override events?

  1. #1
    Join Date
    Feb 2007
    Posts
    73
    Thanks
    11
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy How to prevent shortcut override events?

    I have an embedded app with multiple windows. It can be run on a regular laptop, which is where primary development is done.

    The embedded device has a controller where some buttons act as keyboard events (press/release). When I interpret the mapping in the parent window (via ::event()) on the laptop (with a regular keyboard), everything works fine. But on the embedded device, all ::event ever receives is a ShortcutOverride event, never any key press or release events.

    I tried an event filter on all child windows with the same result. Does anyone have any idea how I can just receive normal events?

  2. #2
    Join Date
    Feb 2007
    Posts
    73
    Thanks
    11
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to prevent shortcut override events?

    Just to reply with a solution I came up with, in case anyone is interested.

    I ended up using an event handler in the child window base class which passes the event to the parent for processing. Then if the parent window doesn't process it, the event handler calls it's immediate base class event handler.

    This seems to work. But I still want to understand why the parent window ::event only gets shortcut override. The documentation on that event is limited at best and it's unclear to me how it would be used and how to turn it off (or on) should that be desired.

  3. #3
    Join Date
    Feb 2007
    Posts
    73
    Thanks
    11
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to prevent shortcut override events?

    It turned out that even the event handler in the child didn't cause KeyPress or KeyRelease events to be sent to the child (or the parent). Only ShortcutOverride events were sent. The solution is to have the QWidget instance that needs to receive the events to call ::grabKeyboard. In my case, it's the parent window that exists for the life of the application. If you call this in child windows whose lifetimes are shorter, ::releaseKeyboard will need to be called too.

    Hope this helps anyone who encounters a similar problem.

  4. The following user says thank you to smacchia for this useful post:

    amleto (27th December 2011)

  5. #4
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to prevent shortcut override events?

    thanks for the update
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Similar Threads

  1. Shortcut key events best practices
    By ducc in forum Qt Programming
    Replies: 4
    Last Post: 21st June 2011, 20:53
  2. Shortcut override ?
    By fenerista in forum Qt Programming
    Replies: 6
    Last Post: 23rd May 2010, 13:02
  3. Cannot override copy shortcut
    By Paladin12 in forum Qt Programming
    Replies: 7
    Last Post: 19th April 2010, 15:56
  4. How to override system shortcut left Alt+Space
    By MasterBLB in forum Qt Programming
    Replies: 2
    Last Post: 28th March 2010, 12:28
  5. override shortcut icon in QToolBar
    By sudhansu in forum Qt Programming
    Replies: 1
    Last Post: 18th February 2010, 09:20

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.