[Qt-interest] Events in Qt event loop vs Windows event loop for a USB/HID device
Girish Ramakrishnan
girish at forwardbias.in
Mon Sep 21 06:50:10 CEST 2009
Serge Briskin wrote:
> Hi,
>
> I'm trying to write a module to communicate with a USB device using HID
> class. I searched the net, got a few useful examples,
> followed in their footsteps (I think). I reimplemented the
> winEventFilter(MSG*, long*), where I put the Windows event loop code
> taken from a working Windows app. The problem I'm facing is that some
> events seem to get through to the code in the
> winEventFilter function, whereas others do not. E.g., I get events for
> WM_DEVICECHANGE (when you plug/unplug a USB
> device), but I do not get any events for e.g. WM_INITDIALOG or
> WM_COMMAND - I suspect they get intercepted by the Qt
> app event loop, and never get through.
> Any help / advice / insight / hint will be greatly appreciated.
>
It's as expected. You will receive all Windows events/messages that your
Qt app receives through winEventFilter. The reason you don't see
WM_INITDIALOG and friends is because Qt never receives them. The reason
is that Qt widgets appear native but they are not native widgets. For
example, QPushButton does not receive BN_CLICKED and friends. Qt just
creates a simple widget and draws a button on it. So, you will see
WM_LBUTTONDOWN on the QPushButton but not a BN_CLICKED.
Girish
More information about the Qt-interest-old
mailing list