[Qt-interest] System-wide shortcut (hotkey)
Matt Rogers
mattr at kde.org
Sun Jan 18 05:11:57 CET 2009
On Tuesday 13 January 2009 01:20:45 Anthony Serdyukov wrote:
> Thanks, I'm looking at QAbstractEventDispatcher too, and that is why.
>
> In the documentation for QCoreApplication::winEventFilter I have found
> the following:
>
> <cite>
> It is only directly addressed messages that are filtered. To handle
> system wide messages, such as messages from a registered hot key, you
> need to install an event filter on the event dispatcher, which is
> returned from QAbstractEventDispatcher::instance().
> </cite>
>
> So, what kind of hot keys are mentioned here... don't know. And how to
> register it properly?
>
First, don't top post, especially to mailing lists and newsgroups. Makes
following a thread nearly impossible (and it's bad netiquette to boot).
So, installing an event filter on the event dispatcher is as simple as the
following snippet:
QAbstractEventDIspatcher* ed = QAbstractEventDispatcher::instance();
QAbstractEventDispatcher::EventFilter ef = &eventFilterFunction;
ed->setEventFilter(ef);
eventFilterFunction is implemented by you to catch the events you want at the
system level.
Hope this helps,
Matt
> 2009/1/13 R. Reucher <rene.reucher at batcom-it.net>:
> > On Tue January 13 2009 06:48:15 Anthony Serdyukov wrote:
> >> Good day.
> >>
> >> I need to set system-wide hotkey and perform some action when it is
> >> fired. The only one discussion I have found is here:
> >> http://lists.trolltech.com/qt-interest/2007-07/thread00221-0.html
> >> But unfortunately, there is no solution there.
> >>
> >> Qt 4.4.3, platform is Windows.
> >
> > As far as I can tell, QAction doesn't support that natively - the
> > highest "level" of the shortcut context is on application level.
> >
> > The only solution I can think of is to use QAbstractEventDispatcher and
> > install an event filter function that does the job... but I've never
> > tried it, so I can't tell if what you are aiming to achieve is really
> > possible this way.
> >
> > There may also be platform dependent ways, of course...
> >
> > HTH, René
> > --
> > René Reucher
> > rene.reucher at batcom-it.net
> > http://www.batcom-it.net/
> >
> > "Biology is the only science in which multiplication means the same
> > thing as division."
> >
> > _______________________________________________
> > Qt-interest mailing list
> > Qt-interest at trolltech.com
> > http://lists.trolltech.com/mailman/listinfo/qt-interest
--
Matt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090117/84f1992a/attachment.bin
More information about the Qt-interest-old
mailing list