Qt-interest Archive, July 2007
Global Hotkeys
Message 1 in thread
Hello.
I'm trying to develop an application that's capable of managing global
hotkeys. What I want is something like letting the user define a hotkey and
also a message that's tied to that hotkey. Then, when the user presses the
key combination, the message would be automatically typed by my application.
It's really simple, but the problems is Qt offers no support for global
hotkeys. This means I could only do it through the Windows API (I'm assuming
it's ok if my application only works on Windows for now).
Well I really have no clue what to do. Creating a system-wide hotkey on
Windows rather easy but it requires having a window handle, which means
platform specific code.
I'm just starting with Qt and global hotkeys isn't well documented, so I got
stuck.
Any advice? Thanks in advance!
--
[ signature omitted ]
Message 2 in thread
Thiago Sfredo wrote:
> Hello.
>
> I'm trying to develop an application that's capable of managing global
> hotkeys. What I want is something like letting the user define a
> hotkey and also a message that's tied to that hotkey. Then, when the
> user presses the key combination, the message would be automatically
> typed by my application.
>
> It's really simple, but the problems is Qt offers no support for
> global hotkeys.
What makes you say that? Have you read the documentation on QAction?
- Keith
--
[ signature omitted ]
Message 3 in thread
On 7/8/07, Keith Sabine <keith@xxxxxxxxxxxxxx> wrote:
> Thiago Sfredo wrote:
> > Hello.
> >
> > I'm trying to develop an application that's capable of managing global
> > hotkeys. What I want is something like letting the user define a
> > hotkey and also a message that's tied to that hotkey. Then, when the
> > user presses the key combination, the message would be automatically
> > typed by my application.
> >
> > It's really simple, but the problems is Qt offers no support for
> > global hotkeys.
>
> What makes you say that? Have you read the documentation on QAction?
Here it is:
> enum Qt::ShortcutContext
> For a QEvent::Shortcut event to occur, the shortcut's key sequence must be
> entered by the user in a context where the shortcut is active.
> The possible contexts are these:
>
> Constant Value Description
> Qt::WidgetShortcut 0 The shortcut is active when its parent widget has focus.
> Qt::WindowShortcut 1 The shortcut is active when its parent widget is a logical subwidget of the active top-level window.
> Qt::ApplicationShortcut 2 The shortcut is active when one of the applications windows are active.
These are all application-level. There is no provision for a
system-level (triggerable when another application has focus)
shortcut.
As for addressing the OP's question, just use RegisterGlobalHotKey().
As for which HWND to use, you could either use the QWidget::winId() of
you app's main window (if it has one) or else create a dedicated
widget and have it permanently hidden.
--
[ signature omitted ]
Message 4 in thread
Hi,
design of application I'm working on is this
a mainwindow and inside plugins install 4 widgets with toolbas inside
and so, actions inside this toolbars.
associated to this actions, hotkeys (shortcuts)
The problem I have is that when one of this widgets inside the
mainwindow loose focus, the shortcut is still enabled.
I tried to control this modifying the default shorcutcontext to be
Qt::WidgetShortcut but this does'nt have the expected effect.
when I set the context with this enum, shortcuts doesn't work anymore.
this occur using 422.
Is someone experimented same effect? is someone can telle me if 430
shotcut contex work as I need?
Thank for any tips of info that could help me to control shortcuts.
Best regards,
Veronique.
> enum Qt::ShortcutContext
Andrew Medico a écrit :
> On 7/8/07, Keith Sabine <keith@xxxxxxxxxxxxxx> wrote:
>
>> Thiago Sfredo wrote:
>> > Hello.
>> >
>> > I'm trying to develop an application that's capable of managing global
>> > hotkeys. What I want is something like letting the user define a
>> > hotkey and also a message that's tied to that hotkey. Then, when the
>> > user presses the key combination, the message would be automatically
>> > typed by my application.
>> >
>> > It's really simple, but the problems is Qt offers no support for
>> > global hotkeys.
>>
>> What makes you say that? Have you read the documentation on QAction?
>
>
> Here it is:
>
>> enum Qt::ShortcutContext
>
>
>> For a QEvent::Shortcut event to occur, the shortcut's key sequence
>> must be
>> entered by the user in a context where the shortcut is active.
>> The possible contexts are these:
>>
>> Constant Value Description
>> Qt::WidgetShortcut 0 The shortcut is active when its parent
>> widget has focus.
>> Qt::WindowShortcut 1 The shortcut is active when its parent
>> widget is a logical subwidget of the active top-level window.
>> Qt::ApplicationShortcut 2 The shortcut is active when one of
>> the applications windows are active.
>
>
> These are all application-level. There is no provision for a
> system-level (triggerable when another application has focus)
> shortcut.
>
> As for addressing the OP's question, just use RegisterGlobalHotKey().
> As for which HWND to use, you could either use the QWidget::winId() of
> you app's main window (if it has one) or else create a dedicated
> widget and have it permanently hidden.
>
--
[ signature omitted ]
Message 5 in thread
Hi,
> I'm trying to develop an application that's capable of managing global
> hotkeys.
How much global? Application-wide or system-wide?
--
[ signature omitted ]