I'm working on an application, which I need to run in the background and run a function when a certain combination of buttons is pressed. I kind of understand that this requires a platform-specific API call (WIN32, X11, etc.), but I don't really know how to start. Also, is there a multi-platform way to achieve this? I really need this to work on Windows, Linux, and OSX.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
To summarize:
- The Qt Event System may be an option (with some help on system/desktop manager level)
- Qxt Library (not longer maintained)
- Or this project UGlobalHotkey
. 2. seems the best option so far. Though it is not longer maintained it currently works with Qt5.
回答2:
http://amin-ahmadi.com/2015/11/14/how-to-use-system-wide-hotkeys-in-your-qt-application/ shows how to use the Windows API's RegisterHotKey in Qt.
You'll need the key code(s) for your hotkey(s).