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
Qt 6.11 is out! See what's new in the release blog

QShortcut blocks keyPressEvent

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 840 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.
  • MegamouseM Offline
    MegamouseM Offline
    Megamouse
    wrote on 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?

    Pl45m4P 1 Reply Last reply
    0
    • MegamouseM Megamouse

      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?

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on 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
      • MegamouseM Offline
        MegamouseM Offline
        Megamouse
        wrote on last edited by
        #3

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

        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