[Interest] Embedding QMacNativeWidget into native window steals keyboard input

Nuno Santos nunosantos at imaginando.pt
Wed Feb 17 13:59:48 CET 2016


Hi,

I’m embedding a QMacNativeWidget into another application plugin window.

Before embedding, the plugin window doesn’t do anything with the keyboard input, so, it flows down to the host, performing utility and important functions. As soon as I embed the QMacNativeWidget into into the plugin window, the keyboard is not received by the host anymore. I have been trying to read about widget and window flags and trying a lot of them without luck. Also, the window close button doesn’t work anymore.

Does anyone knows how can I prevent this behaviour? 

Below is the code I use to embed the QMacNativeWidget into the host plugin window:

QMacNativeWidget *nativeWidget = new QMacNativeWidget();

nativeWidget->setPalette(QPalette(Qt::red));
nativeWidget->setAutoFillBackground(true);
nativeWidget->setWindowFlags(Qt::Tool | Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus | Qt::WindowCloseButtonHint);
nativeWidget->clearFocus();
nativeWidget->releaseKeyboard();
nativeWidget->setAttribute(Qt::WA_ShowWithoutActivating);
nativeWidget->setAttribute(Qt::WA_NativeWindow);

NSView *nativeWidgetView = reinterpret_cast<NSView *>(nativeWidget->winId());

if ([view isKindOfClass:[NSView class]])
{
    [view addSubview:nativeWidgetView];
}
else
{
    #ifdef USE_CARBON_WINDOW
    HIRect frame;
    HIViewRef content;
    WindowRef w= (WindowRef) ptr;

    HIViewFindByID(HIViewGetRoot(w), kHIViewWindowContentID, &content);
    HIViewGetFrame(content, &frame);

    frame.origin.x=0;
    frame.origin.y=0;

    HICocoaViewCreate(0, 0, &hiCocoaView);
    HIViewSetFrame(hiCocoaView, &frame);
    HIViewAddSubview(content, hiCocoaView);
    HICocoaViewSetView(hiCocoaView, nativeWidgetView);
    #endif
}

nativeWidget->show(); 

Nuno

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160217/3a7cfd3c/attachment.html>


More information about the Interest mailing list