QHotkey

1.下载

  https://github.com/Skycoder42/QHotkey

2.使用

 1 #include <QHotkey>
 2 #include <QApplication>
 3 #include <QDebug>
 4 
 5 int main(int argc, char *argv[])
 6 {
 7     QApplication app(argc, argv);
 8 
 9     QHotkey hotkey(QKeySequence("Ctrl+Alt+Q"), true, &app); //The hotkey will be automatically registered
10     qDebug() << "Is segistered:" << hotkey.isRegistered();
11 
12     QObject::connect(&hotkey, &QHotkey::activated, qApp, [&](){
13         qDebug() << "Hotkey Activated - the application will quit now";
14         qApp->quit();
15     });
16 
17     return app.exec();
18 }

 

posted @ 2024-03-19 17:15  wuyuan2011woaini  阅读(47)  评论(0编辑  收藏  举报