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

Setting WA_NativeWindow on QQuickWidget doesn't render anymore, all black

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P1: Critical
    • None
    • 6.8.3
    • Qt RHI
    • None
    • Windows

    Description

      We wanted to embed a QQuickWidget in a docking container within our QMainWindow, without running through the render surface type conversion of the mainwindow's default raster surface to direct3d/opengl surface. According to the recent fixes done for QTBUG-119221 , this should be now doable by setting the Qt::WA_NativeWindow on the quickwidget. 
      See comment from vestbo in QTBUG-119221 and related defect:

      Set Qt::WA_NativeWindow on the QOpenGLWidget/QRhiWidget/QQuickWidget/QWebEngineView, or one of its parent widgets, to composit only that widget's hiearchy using RHI. The parent widget hierarchy should not be affected (WA_DontCreateNativeAncestors and AA_DontCreateNativeWidgetSiblings still apply as normal).

      541664 adds support for separate RHI flushing per native window.

      But when setting the Qt::WA_NativeWindow flag the quickwidget doesn't render anymore and window content is black.

      This is a simplified repro sample with a quickwidget in a dialog, instead of a dockwidget, but the same occurs when you try to put the quickwidget in a dockwidget:

      #include <QtWidgets/QApplication>
      #include <QtWidgets/QtWidgets>
      #include <qquickwidget.h>
      
      class QuickWidgetDialog : public QDialog
      {
      public:
      	QuickWidgetDialog(QWidget* parent = nullptr)
      		: QDialog(parent, Qt::Dialog)
      	{
      		setWindowTitle("QuickWidget Dialog Host");
      		setAttribute(Qt::WA_DeleteOnClose, true);
      
      		auto horzLayout = new QHBoxLayout(this);
      		auto quickWidget = new QQuickWidget();
      		quickWidget->setAttribute(Qt::WA_NativeWindow);
      		quickWidget->setSource(QUrl::fromLocalFile("Panel.qml"));
      		horzLayout->addWidget(quickWidget);
      	}
      };
      
      int main(int argc, char** argv)
      {
      	QApplication app(argc, argv);
      
      	auto dlg = new QuickWidgetDialog();
      	dlg->resize(640, 480);
      	dlg->show();
      
      	return app.exec();
      }
      

      Note, that with the recent changes in QWidget::setParent() releated to RHI & setting up the backing store, everything strongly depends on whether at parenting time the parent's windowHandle() is already created or not, see closestParentWidgetWithWindowHandle().

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            vestbo Tor Arne Vestbø
            roman_w Roman Woelker
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes