Embedding window inside Illustrator panel does not load 3D model on Mac



  • Hi All,

    I am developing an Illustrator plugin for Win and Mac.

    Inside the plugin panel window, I show a Qt window that displays a 3D model.
    I am able to get it working on windows.

    Its like this,

    AIPanel(window)

    QMainWindow

    QWindow

    Now, on Mac, things behave differently,
    First, the QMainWindow title bar can be seen outside the frame of the AIPanel whereas the rest of the window is inside the panel window.
    Second, I get no error, but the 3D model never shows up.

    I use this to embed the window on Mac,

    QMacNativeWidget *nativeWidget = new QMacNativeWidget();
    nativeWidget->move(0, 0);
    nativeWidget->setPalette(QPalette(Qt::red));
    nativeWidget->setAutoFillBackground(true);
    QVBoxLayout *layout = new QVBoxLayout();
    layout->addWidget(mainWindow);
    nativeWidget->setLayout(layout);
    
    NSView* nativeWidgetView = reinterpret_cast<NSView*>(nativeWidget->winId());
    [panelWindow setFrame:[nativeWidgetView frame]];
    [panelWindow addSubview:nativeWidgetView positioned:NSWindowAbove relativeTo:nil];
    nativeWidget->show();
    mainWindow->show();
    

    And this on Win,

    SetWindowLong((HWND)mainWindow->winId(), GWL_STYLE, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
    SetParent((HWND)mainWindow->winId(), panelWindow);
    

    Can anyone guide me a bit here? I thought the code would be cross-platform.

    Please help.


  • Qt Champions 2016

    Hi
    Im 100% Mac ignorant so just guessing.

    The native thing you create
    QMacNativeWidget *nativeWidget = new QMacNativeWidget();
    You set no owner. it seems. so on windows that would make it float. ( for QWidgets normally)

    It can accept a parentView in the ctor
    MacNativeWidget::QMacNativeWidget(NSView *parentView = Q_NULLPTR)

    So Im wondering if something like that?

    For the windows version, you do set parent
    SetParent((HWND)mainWindow->winId(), panelWindow);

    Sorry if completely off. Never programmed for Macintosh.



  • @mrjj
    Thanks for the reply!
    I followed your advice and tried setting the panelWindow as the parent...
    No change..

    Any other ideas?
    I followed this link,
    http://doc.qt.io/qt-5/qmacnativewidget.html#details



Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.