https://github.com/mrousavy/qhotkeys
🔠A small and lightweight cross platform C++ library implementing a system-wide hotkey system for Qt
https://github.com/mrousavy/qhotkeys
global hotkey hotkeys library linux macos qt windows
Last synced: 9 months ago
JSON representation
🔠A small and lightweight cross platform C++ library implementing a system-wide hotkey system for Qt
- Host: GitHub
- URL: https://github.com/mrousavy/qhotkeys
- Owner: mrousavy
- License: mit
- Created: 2018-02-11T10:07:09.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-06-18T08:42:14.000Z (about 6 years ago)
- Last Synced: 2025-04-06T03:33:31.313Z (about 1 year ago)
- Topics: global, hotkey, hotkeys, library, linux, macos, qt, windows
- Language: C++
- Homepage:
- Size: 23.4 KB
- Stars: 11
- Watchers: 3
- Forks: 9
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# QHotkeys
🔠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
## Usage
#### Install
Run this command in your project's directory:
```sh
git submodule add https://github.com/mrousavy/QHotkeys
```
Add these lines to your Qt Project file (`.pro`):
```qmake
include(QHotkeys/QHotkeys.pri)
DEPENDPATH += QHotkeys/src/
INCLUDEPATH += QHotkeys/src/
```
#### Code
```cpp
#include
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);
```