[Qt-interest] setMouseTracking
Nikos Chantziaras
realnc at arcor.de
Sat Jan 8 00:18:57 CET 2011
On 01/08/2011 12:58 AM, william.crocker at analog.com wrote:
>
>>>>>
>>>>> Right on and thanks a lot to everyone (and esp. Bill for the final
>>>>> idea)
>>>> Of course you should know that this makes your application run code
>>>> all the time, waking up the CPU even when idle. Users are known to
>>>> throw darts at pictures of the developer for stuff like this :-)
>>>>
>>> I agree.
>>> You should query at the lowest acceptable frequency.
>>> You could then scale the frequency up and down with
>>> the apparent mouse velocity.
>>
>> I think the best approach to this is to simply write a custom event
>> filter and install it on the global application pointer. And here's
>> how it's done:
>>
>
> I was under the impression that he wanted to track the mouse
> (no buttons pressed) even when it was not over the subject application.
In that case you can use QApplication::x11EventFilter() if you're on
Linux and receive events directly from X11. This is platform-specific
of course and won't work on Windows or the Mac.
For Windows, maybe the last post of this thread helps:
http://www.qtcentre.org/threads/9213-Can-Qt4-capture-mousePress-events-on-the-desktop
But I think the OP wanted a global application mouse event handler that
works regardless of whether the mouse enters widgets or not, in which
case the eventFilter() example I provided is probably the best way to do it.
More information about the Qt-interest-old
mailing list