🔠A small and lightweight cross platform C++ library implementing a system-wide hotkey system for Qt
There are implementations available for the following compilers/platforms:
- msvc - Windows
- linux - Linux/X11
- macx - MacOSX
Run this command in your project's directory:
git submodule add https://github.com/mrousavy/QHotkeys
Add these lines to your Qt Project file (.pro
):
include(QHotkeys/QHotkeys.pri)
DEPENDPATH += QHotkeys/src/
INCLUDEPATH += QHotkeys/src/
#include <qhotkeys.h>
using namespace Qt;
// ...
void myCallback(const QHotkey& hotkey) {
// This is executed on a seperate thread!
cout << "Hotkey pressed!";
}
// ...
// Register the hotkey
QHotkey hotkey(ModifierKey::Control | ModifierKey::Alt, Key_I);
// Connect pressed signal to one or more callback slots
QObject::connect(&hotkey, &QHotkey::pressed, &myCallback);