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
For Gerrit Dashboard: QTBUG-113557 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
477595,6 | Refine the rhi-based flush logic | dev | qt/qtbase | Status: MERGED | +2 | 0 |
481137,2 | Refine the rhi-based flush logic | 6.5 | qt/qtbase | Status: MERGED | +2 | 0 |
494220,4 | Fix texture-based non-native child of a non-texture-based native child | dev | qt/qtbase | Status: MERGED | +2 | 0 |
496687,3 | Fix texture-based non-native child of a non-texture-based native child | 6.6 | qt/qtbase | Status: MERGED | +2 | 0 |
496688,3 | Fix texture-based non-native child of a non-texture-based native child | 6.5 | qt/qtbase | Status: MERGED | +2 | 0 |
541664,33 | widgets: Use per-surface-format RHI support and compositor | dev | qt/qtbase | Status: MERGED | +2 | 0 |
544021,9 | widgets: Use per-surface-format RHI support and compositor | tqtc/lts-6.5 | qt/tqtc-qtbase | Status: DEFERRED | 0 | 0 |