[Interest] [OS X] creating a QDialog from a WId?

Nuno Santos nunosantos at imaginando.pt
Wed Dec 9 09:30:44 CET 2015


Yes, I’m writing a plugin and the ptr is a NSView provided by the host.

I had already tried several other options until I found QMacNativeWidget to the rescue. It works like charm now.

Sorry, I don’t know what KF5 is.

Nuno

> On 09/12/2015, at 00:05, René J. V. Bertin <rjvbertin at gmail.com> wrote:
> 
> Nuno Santos wrote:
> 
> 
> Hello Nunos,
> 
> Have you tried using a `ptr` that comes from another application? I think that's 
> the context in which I get the crash.
> 
> I'll keep your code in mind though; the crash issue also reminded me that KF5 
> KWindowSystem doesn't yet have a plugin (backed) implemented for OS X, so I'm 
> porting the one from KDE4... Fun times!
> 
> R.
> 
>> Rene,
>> 
>> I have recently dealt with creating content within a native window on mac
>> given a pointer. This was I got to:
>> 
>> QMacNativeWidget* IVstEditor::fromWindowRef(void *ptr)
>> {
>>    NSView* view = (NSView*) ptr;
>> 
>>    QMacNativeWidget *nativeWidget = new QMacNativeWidget(view);
>> 
>>    nativeWidget->move(0, 0);
>>    nativeWidget->setPalette(QPalette(Qt::red));
>>    nativeWidget->setAutoFillBackground(true);
>>    nativeWidget->setWindowFlags(Qt::FramelessWindowHint |
>>    Qt::WindowDoesNotAcceptFocus);
>> 
>>    NSView *nativeWidgetView = reinterpret_cast<NSView
>>    *>(nativeWidget->winId());
>> 
>>    [view addSubview:nativeWidgetView];
>> 
>>    nativeWidget->show();
>> 
>>    return nativeWidget;
>> }
>> 
>> I don’t know if you can turn a simple widget into a QDialog but maybe you can
>> find something useful here.
> 
> 
> 
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest




More information about the Interest mailing list