Using spacebar as a shortcut
-
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?
-
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.
-
eventFilter and installEventFilter look like they should do the job...thanks for the tip!
-
Setting a [[Doc:QShortcut]] on the application and/or main window should work too.