QSystemHotkey
-
Hello,
I have a system wide hotkey class and created for my Qt5.1 app, "QSystemHotkey":https://github.com/CCi-BClark/SystemHotkey. Since there is not a class that does this I figured I would give a go at submitting it to the Qt5 library. How could I go about making it a better suited candidate?
Currently it is implemented with the QApplication::processEvents() function to ensure the UIX doesn't freeze like so:
@
void hotkeyPressed(int position); //Handle hotkey SIGNAL//Create data type.
STDSystemHotkey *hotkeys;//Connect data type to hadler function.
connect(hotkeys, SIGNAL(runHotkey(int)),this,SLOT(hotkeyPressed(int)));hotkeys->addKey(200,MOD_ALT,'X'); //Add hotkey to system.
QApplication::processEvents();
hotkeys->beginHotkeys(); //Start listening for hotkeys.hotkeyPressed(int position){
int val = hotkey->getHotkey(position);
switch (val) {
case 200:
//function to run
break;
default:
break;
}
}hotkeys->haultHotkeys(); //Stop listening for hotkeys.
@ -
You can use a queued signal and slot connection plus a QTimer to "order" your hotkey handling function to be run.
If you want to contribute the code to Qt, you need to follow "the official guidelines":http://wiki.qt-project.org/Main_Page
Definitely it should work on Mac and Linux, apart from Windows.