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. Problem with getting a keyPressEvent for arrow keys
Forum Updated to NodeBB v4.3 + New Features

Problem with getting a keyPressEvent for arrow keys

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 136 Views 2 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.
  • J Offline
    J Offline
    james b-s
    wrote on last edited by
    #1

    I have an application with a QGraphicsView. When I use the arrow keys, things scroll as I expect.

    I also have a QObject on the screen. When I hover over the QObject, I pop up a QDialog.

    While the QDialog is displayed, the arrow keys no longer work. The other keys (letter and number keys) still work fine. Neither the keyPressEvent method or the main event method are called for the arrow keys, but they are both called for letter keys.

    I've tried overriding the keyPressEvent and the event methods for every class I can think of, for the QObject, for the QDialog, for QGraphicsView, for QGraphicsScene, and none of those get called for arrow keys when that hover dialog is up, but the right ones are called when I press a letter key.

    I even set the focus policy to strong focus as some online have suggested. It didn't change the behavior.

    I think I've run out of things to try. Anyone have any suggestions?

    Windows 11. Qt 5.15

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      The best thing to do would be to create a minimal compilable reproducer so that people can check what might be going on.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      J 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        The best thing to do would be to create a minimal compilable reproducer so that people can check what might be going on.

        J Offline
        J Offline
        james b-s
        wrote on last edited by
        #3

        @SGaist I would do that if I thought it was possible.

        A debugging Qt would help, but we aren't set up for that here.

        Does Qt have any internal logging that could be turned on in a release build that might help? I'd love to see who is swallowing the arrow keys.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Are you using a custom Qt build ?
          One thing you can do is check the Qt Logging Category.
          There are multiple used in Qt's own code.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          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