Details
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
- duplicates
-
QTBUG-113652 [REG 6.3.2 -> 6.4] Native QOpenGLWidget in QMainWindow breaks menu bar
- Closed
- relates to
-
QTBUG-108344 Something is rotten with texture-based widgets that are native child widgets or are children of a native child widget
- Closed