View Full Version : How to realize the hotKey function?

1st July 2009, 02:46
I have an application with Qt3 run in Win32 and Unix.
And now I want my applicatoin support the hotkey function.
the function like those:
when the function is minimumed,I can define the hotkey like "Ctrl+1" to maximized it!
when the function lose the focuse,I can define the hotKey like "Ctrl+2" to display the front.

for my application run in Win32 and Unix,so I want this function all support in this two platform.

and in Win32,I use the SetWindowsHookEx API to realsize my function,but I don't know how to realize it in Unix.

also,in Qt3,weather has the function?like QAccell or other?

1st July 2009, 12:12
You can use XGrabKey(). The Psi IM client has a GlobalShortcutManager (http://dev.psi-im.org:8080/browse/~raw,r=224/psi/trunk/src/tools/globalshortcut/globalshortcutmanager_x11.cpp) class that does the trick. You may take a look at it. The Qxt library also has global shortcuts using QxtGlobalShortcut (http://doc.libqxt.org/0.5.0/classQxtGlobalShortcut.html). Both are for Qt 4 but you can take a look at it to make your own implementaion.