How to re-direct keyboard events from Qt to Win32 windows?
Hi, I have a Qt window, its parent is a Win32 window.
I want to re-direct all keyboard events to the Win32 window, e.g. let it handle application shortcuts.
The code is like this,
I think, what you need is the following:
- class QChild : public QWidget
- bool winEvent(MSG* message, long* result)
- if(WM_KEYDOWN == message->message)
- HWND hWndParent = ::GetParent(WinId());
- if(0 != hWndParent)
- *result = ::SendMessage(, message->message, message->lParam, message->wParam);
Building the correct WPARAM for the WM_KEYDOWN event is not so easy, as it contains scan codes etc (WM_KEYDOWN on MSDN [msdn.microsoft.com]).aspx ). Make sure to also foreward the WM_KEYUP event. You could also just do a filtering before forewarding etc.