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

keyPressEvent not being called

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 535 Views 3 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.
  • PerdrixP Offline
    PerdrixP Offline
    Perdrix
    wrote on last edited by
    #1

    Main window has a keyPressEvent handler and sets "strong focus" policy in order to intercept F1 on Windows/Unix or Command-? on MacOS

    The main window has a two Dock windows. If they are docked then F1 is passed up the child/parent chain to the main window and the main window keyPressEvent is driven and the help is displayed.

    When they are un-docked and have focus, when I press F1, then the main window's keyPressEvent() isn't called.

    Pl45m4P M 2 Replies Last reply
    0
    • PerdrixP Perdrix

      Main window has a keyPressEvent handler and sets "strong focus" policy in order to intercept F1 on Windows/Unix or Command-? on MacOS

      The main window has a two Dock windows. If they are docked then F1 is passed up the child/parent chain to the main window and the main window keyPressEvent is driven and the help is displayed.

      When they are un-docked and have focus, when I press F1, then the main window's keyPressEvent() isn't called.

      M Offline
      M Offline
      mpergand
      wrote on last edited by
      #3

      @Perdrix said in keyPressEvent not being called:

      When they are un-docked and have focus, when I press F1, then the main window's keyPressEvent() isn't called.

      Because main window hasn't the focus.
      You may try a global QShortcut with context set to Qt::ApplicationShortcut

      PerdrixP 1 Reply Last reply
      2
      • PerdrixP Perdrix

        Main window has a keyPressEvent handler and sets "strong focus" policy in order to intercept F1 on Windows/Unix or Command-? on MacOS

        The main window has a two Dock windows. If they are docked then F1 is passed up the child/parent chain to the main window and the main window keyPressEvent is driven and the help is displayed.

        When they are un-docked and have focus, when I press F1, then the main window's keyPressEvent() isn't called.

        Pl45m4P Offline
        Pl45m4P Offline
        Pl45m4
        wrote on last edited by Pl45m4
        #2

        @Perdrix said in keyPressEvent not being called:

        When they are un-docked and have focus, when I press F1, then the main window's keyPressEvent() isn't called.

        Playing with undocked QDockWidgets and focus() seems to be a weird thing. There are a lot of partly/not resolved topics dealing with this here and on StackO...
        It also seems to be platform dependent and every OS treats the undocked windows/widgets slightly different.

        • https://forum.qt.io/post/757424

        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
        0
        • PerdrixP Perdrix

          Main window has a keyPressEvent handler and sets "strong focus" policy in order to intercept F1 on Windows/Unix or Command-? on MacOS

          The main window has a two Dock windows. If they are docked then F1 is passed up the child/parent chain to the main window and the main window keyPressEvent is driven and the help is displayed.

          When they are un-docked and have focus, when I press F1, then the main window's keyPressEvent() isn't called.

          M Offline
          M Offline
          mpergand
          wrote on last edited by
          #3

          @Perdrix said in keyPressEvent not being called:

          When they are un-docked and have focus, when I press F1, then the main window's keyPressEvent() isn't called.

          Because main window hasn't the focus.
          You may try a global QShortcut with context set to Qt::ApplicationShortcut

          PerdrixP 1 Reply Last reply
          2
          • M mpergand

            @Perdrix said in keyPressEvent not being called:

            When they are un-docked and have focus, when I press F1, then the main window's keyPressEvent() isn't called.

            Because main window hasn't the focus.
            You may try a global QShortcut with context set to Qt::ApplicationShortcut

            PerdrixP Offline
            PerdrixP Offline
            Perdrix
            wrote on last edited by
            #4

            @mpergand Yes! Using a QShortcut with context Qt::ApplicationShortcut and key sequence QKeySequence::HelpContents worked a treat!

            Thanks a lot

            1 Reply Last reply
            0
            • PerdrixP Perdrix has marked this topic as solved on

            • Login

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