Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-43183

QMacNativeWidget makes a new window

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • None
    • 5.4.0 RC
    • Extras: Mac
    • None
    • MacOS X 10.10
    • macOS

    Description

      First of all, I glad to see there are less bugs with QMacNativeWidget (QLineEdit focus issues, rendering issues, borderless window)

      I made a simple test with QMacNativeWidget.
      I used it in a plug-in for Adobe Illustrator CC.

      There is something strange, a piece of a window appears somewhere.
      It seems that the QMacNativeWidget creates a window instead of using the provided view

      // The code I used, hDlg here is a NSView
      {
      QMacNativeWidget *nativeWidget = new QMacNativeWidget(hDlg);
      nativeWidget->move(0, 0);
      nativeWidget->setPalette(QPalette(Qt::red));
      nativeWidget->setAutoFillBackground(true);
      QVBoxLayout *layout = new QVBoxLayout();
      QLineEdit *pushButton = new QLineEdit("An Embedded Qt Button!", nativeWidget);
      pushButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // Don't use the layout rect calculated from QMacStyle.
      layout->addWidget(pushButton);
      nativeWidget->setLayout(layout);

      // Adjust Cocoa layouts
      NSView *nativeWidgetView = reinterpret_cast<NSView *>(nativeWidget->winId());
      NSView *contentView = hDlg;//[window contentView];
      [contentView setAutoresizesSubviews:YES];
      [nativeWidgetView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
      [nativeWidgetView setAutoresizesSubviews:YES];

      { NSView *pushButtonView = reinterpret_cast<NSView *>(pushButton->winId()); [pushButtonView setAutoresizingMask:NSViewWidthSizable]; }

      // Add the nativeWidget to the window.
      [contentView addSubview:nativeWidgetView];
      nativeWidget->show();
      pushButton->show();
      }

      A trial version of Adobe Illustrator CC 2014 and the SDK are available.
      If you want to try, I can send you a xcode project.

      Attachments

        Activity

          People

            sorvig Morten Sørvig
            nosleduc nosleduc
            Votes:
            5 Vote for this issue
            Watchers:
            9 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: