[Qt-interest] System-wide shortcut (hotkey)
Matt Rogers
mattr at kde.org
Sat Jan 24 21:00:10 CET 2009
On Sunday 18 January 2009 20:55:23 Anthony Serdyukov wrote:
> The documentation i have cited says "install event filter". So, I
> thought they mean QObject::installEventFilter() method.
> But Matt has pointed out another method
> QAbstractEventDispatcher::setEventFilter, whic is specific to
> QAbstractEventDispatcher.
> So, what is the difference between theses two event filters besides
> signatures and OO/functional styles? i.e. what events are filtered by
> which filter?
>
QAbstractEventDispatcher::setEventFilter allows you to add a filter to system
wide events. QObject::installEventFilter only works on a particular object's
events.
> And what kind of filtering is the cited documentation talking about?
>
Platform specific filtering. That's why the signatures are different. For each
platform, you're required to cast the void* to that platform's specific event
type.
> 2009/1/18 Matt Rogers <mattr at kde.org>:
> > 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é
--
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/20090124/4b14e628/attachment.bin
More information about the Qt-interest-old
mailing list