Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++/Qt Global Hotkeys [duplicate]

Tags:

c++

hotkeys

qt

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.

like image 895
rettetdemdativ Avatar asked Feb 22 '16 21:02

rettetdemdativ


2 Answers

To summarize:

  1. The Qt Event System may be an option (with some help on system/desktop manager level)
  2. Qxt Library (not longer maintained)
  3. Or this project UGlobalHotkey

. 2. seems the best option so far. Though it is not longer maintained it currently works with Qt5.

like image 58
holzkohlengrill Avatar answered Sep 29 '22 12:09

holzkohlengrill


Take a look at https://github.com/kwhat/libuiohook

Its a c library that can easily be integrated with Qt. Allows both global keyboard and mouse events listeners.

or

https://github.com/Skycoder42/QHotkey

This one is a Qt based library and seems to be maintained.

like image 26
Atul Avatar answered Sep 29 '22 11:09

Atul