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. Make application to respond to space bar presses/releases
QtWS25 Last Chance

Make application to respond to space bar presses/releases

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 973 Views
  • 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.
  • A Offline
    A Offline
    A1exander_Z
    wrote on last edited by
    #1

    I need to make my application to respond to space bar press and release events. Autorepeats must be filtered out in order to respond only to actual key presses and releases (the key may be pressed and hold for a few seconds), so, as I understand, I cannot use the shortcut mechanism present in Qt.

    I have tried to reimplement keyPressEvent/keyReleaseEvent or eventFilter in the application's main window class. Initially both of these approaches work, but after adding some child widgets to the main window it stops to respond to KeyPress events, and after selecting one of the child widgets (e.g. a radio button) KeyRelease events also disappear. I understand that the events are intercepted by child widgets, but I do not know how to disable such behavior.

    The main window has several tabs and one of them contains a text editor. Ideally I would like to completely disable processing of space bar events in the main window by anything except my own handlers when the editor tab is not selected. Separate dialog windows also need to work as usual, because they have some text input fields. The application is cross-platform and solution to this problem also has to be OS agnostic. Is it possible?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dbzhang800
      wrote on last edited by
      #2

      You can simply add a event filter to your application, then you can deal with all the spaceBar press/release event there.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        A1exander_Z
        wrote on last edited by
        #3

        Thank you, it seems to be working. As I understand, I have to remove the filter each time before showing a dialog and to reinstall it afterwards, but fortunately there are only a few dialog calls.

        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