PDA

View Full Version : Using RegisterHotKey



steenvinkel
22nd February 2007, 17:27
I have a simple program with a widget. At startup the widget is not shown.

I want to assign a hotkey ( for instance "ctrl + space" ). So when the user pressses "ctrl + space" the widget is shown.

I know i can register the hotkey with

RegisterHotKey(winId(), 100, MOD_CONTROL, VK_SPACE);

But how do i get and react on the messages windows sends when the user presses "ctrl + space" and should RegisterHotKey(); be place anywhere specific in the code?

Methedrine
24th February 2007, 16:00
Sorry, misunderstood your problem, QShortCut won't install system-wide hotkeys

But you could always try to implement your own messageFilter.

jpn
24th February 2007, 16:15
The message can be caught via QWidget::winEvent().

steenvinkel
25th February 2007, 14:52
Thank you for your answers. I got it to work with QWidget::winEvent().