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

GrabKeyboard troubles

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.3k 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.
  • W Offline
    W Offline
    wisellers
    wrote on last edited by
    #1

    I have a main window with a big OpenGL widget that I manipulate 3D objects in. Some of this manipulation is done with keyboard presses so I grab the keyboard in enterEvent and release it in the leaveEvent. This is fine but I also have floating tool bars and dialog boxes that pop up over the big widget. None of the controls (QTextEdit and QSpinBox widgets) get any keyboard input any more - presumably because the mouse is still within the OpenGL widget and so no leave event has been generated. Is there another event I should be trapping to release the keyboard to get all these controls to work as expected when widgets overlap? Perhaps I could do it by trapping QEvent::CursorChange but that seems a bit of an ugly hack. QEvent::WindowBlocked should work for for the dialogs.

    Cheers
    Bill

    1 Reply Last reply
    0
    • W Offline
      W Offline
      wisellers
      wrote on last edited by
      #2

      I've got around this by subclassing the QTextEdit and QSpinBox classes so they send enter and leave signals which I can use to grab and ungrab the keyboard. It still isn't at all neat, and not 100% reliable which surprises me. Am I always guaranteed that each enter event will be paired by a leave event?

      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