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

Raster native widget fail to draw when there is a quick widget sibling

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • 6.5.2, 6.6.0 FF
    • 6.5.0
    • Qt RHI
    • None
    • 8c0b657c9 (dev), d397fee62 (6.5), 373c08d03 (dev), 56079c1a4 (6.5), 3e09f3abb (6.6)

    Description

      Please use this code to reproduce.

      #include <QtWidgets/QApplication>
      #include <QtWidgets/QWidget>
      #include <QtGUI/QPainter>
      #include <QtOpenGLWidgets/QOpenGLWidget>
      
      int main(int argc, char** argv)
      {
          QApplication app(argc, argv);
      
          // tlw, by default it's Raster.
          QWidget tlw;
          tlw.resize(640, 480);
      
          // adding opengl/qml/webengine will change tlw to be opengl-based
          QOpenGLWidget quick(&tlw); // Or webengine
          quick.setGeometry(0, 0, 640, 240);
      
          // a Raster native sibling
          QWidget raster(&tlw);
          raster.setGeometry(0, 240, 640, 240);
          raster.setStyleSheet("QWidget { background-color: yellow; }");
      
          // Error: QOpenGLContext::makeCurrent() called with non-opengl surface after this line.
          raster.winId();
      
          // Now we have the following window hierarchy:
          //
          //   tlw: OpenGL, native, usesRhiFlush=true
          //    |
          //    +-- quick: texture-based, alien
          //    |
          //    +-- raster: Raster, native
          //
          // The raster native widget will fail to flush to its native window. Because
          // QWidgetRepaintManager::flush() only checks tlw's usesRhiFlush flag. But
          // not all its child windows are Rhi widget. In this case, one of the child
          // is raster window but rhi flush is used.
          //
      
          tlw.show();
          return app.exec();
      }
      

      The error in console will look like:

      QOpenGLContext::makeCurrent() called with non-opengl surface 0x248220072d0
      QRhiGles2: Failed to make context current. Expect bad things to happen.
      

      The native child widget is expected to be yellow.

      Attachments

        Issue Links

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

          Activity

            People

              lagocs Laszlo Agocs
              mingxiang Mingxiang Xu
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: