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. Using spacebar as a shortcut
Forum Updated to NodeBB v4.3 + New Features

Using spacebar as a shortcut

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 2.4k 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.
  • B Offline
    B Offline
    brianz
    wrote on last edited by
    #1

    In my application I'd like to use the spacebar as a shortcut/hot key, similar to how iTunes uses the spacebar: starting or stopping a song, or some action in my case.

    I haven't starting digging into this, but because my application has text areas, it seems like I'd have to keep track of whether any of the text area widgets have focus, and disable the spacebar shortcut if that's the case.

    Am I on the right track here?

    1 Reply Last reply
    0
    • P Offline
      P Offline
      p-himik
      wrote on last edited by
      #2

      You can try to reimplement "event()":http://developer.qt.nokia.com/doc/qt-4.8/qobject.html#event function of your application or, if it doesn't help, create a class with "eventFilter()":http://developer.qt.nokia.com/doc/qt-4.8/qobject.html#eventFilter implemented and call "installEventFilter()":http://developer.qt.nokia.com/doc/qt-4.8/qobject.html#installEventFilter for every widget that uses spacebar.

      1 Reply Last reply
      0
      • B Offline
        B Offline
        brianz
        wrote on last edited by
        #3

        eventFilter and installEventFilter look like they should do the job...thanks for the tip!

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          Setting a [[Doc:QShortcut]] on the application and/or main window should work too.

          http://www.catb.org/~esr/faqs/smart-questions.html

          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