[Development] How to pass key-press/mouse-wheel events to underlying window after QWidget::createWindowContainer()

Sze Howe Koh szehowe.koh at gmail.com
Sun Jul 20 07:59:20 CEST 2014


On 16 July 2014 08:20, Sze Howe Koh <szehowe.koh at gmail.com> wrote:
> Hello,
>
> I'm on Windows 8.1 ×64. I got a HWND from an external process
> (Notepad.exe, in this case) and embedded it inside a QWidget:
>
> // Get the HWND using Windows API
> WId id = (WId)FindWindow(NULL, L"Untitled - Notepad");
>
> // Embed the window in a widget
> QWindow* window = QWindow::fromWinId(id);
> QWidget* widget = QWidget::createWindowContainer(window);
> widget->show();
>
>
> The embedded Notepad can receive mouse clicks and drags -- I can use
> the mouse to highlight text, and use the right-click menu to
> copy+paste text. However,, it doesn’t respond to mouse wheels and key
> presses. Does anyone know how I can restore these events?
>
> I got the same results from both MinGW 4.8.2 and MSVC 2013 (both Qt 5.3.1).
>
>
> Thanks in advance!

Looks like a bug in the Windows implementation -- The issue doesn't
exist on Ubuntu 14.04.

I've opened https://bugreports.qt-project.org/browse/QTBUG-40320 which
contains a list of issues related to embedding and releasing foreign
windows in both Windows and Linux.


Regards,
Sze-Howe



More information about the Development mailing list