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. QShortcut blocks keyPressEvent
Forum Updated to NodeBB v4.3 + New Features

QShortcut blocks keyPressEvent

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 170 Views 1 Watching
  • 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.
  • M Offline
    M Offline
    Megamouse
    wrote on 31 Mar 2025, 09:06 last edited by
    #1

    Hi,

    I've set up some configurable QShortcuts in our project. They are then attached to the QWindow.
    I also use keyPressEvents to get normal user input in the window.

    The problem is that as soon as the user presses a shortcut, there is no propagation of the keyPressEvent anymore.
    So for example if you press Shift+M and a shortcut is setup for that, then there will only be a Shift event but no M event. The shortcut works of course, but now it's impossible for the user to enter uppercase M unless they use capslock.

    Is there a way to tell QShortcut to keep propagating the event?

    P 1 Reply Last reply 31 Mar 2025, 13:01
    0
    • M Megamouse
      31 Mar 2025, 09:06

      Hi,

      I've set up some configurable QShortcuts in our project. They are then attached to the QWindow.
      I also use keyPressEvents to get normal user input in the window.

      The problem is that as soon as the user presses a shortcut, there is no propagation of the keyPressEvent anymore.
      So for example if you press Shift+M and a shortcut is setup for that, then there will only be a Shift event but no M event. The shortcut works of course, but now it's impossible for the user to enter uppercase M unless they use capslock.

      Is there a way to tell QShortcut to keep propagating the event?

      P Offline
      P Offline
      Pl45m4
      wrote on 31 Mar 2025, 13:01 last edited by Pl45m4
      #2

      @Megamouse

      Hi,
      QEvent::ShortcutOverride might be the right thing for you in this case.
      (override the shortcut when typing text)

      • https://wiki.qt.io/ShortcutOverride

      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      1 Reply Last reply
      2
      • M Offline
        M Offline
        Megamouse
        wrote on 1 Apr 2025, 08:20 last edited by
        #3

        Thank you!
        I'll take a look and report back

        1 Reply Last reply
        0

        3/3

        1 Apr 2025, 08:20

        • Login

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