Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
None
-
6.5.3
-
None
Description
Qt version is 6.5.3 + https://codereview.qt-project.org/c/qt/qtbase/+/541664 patch. Should be reproducible in dev + https://codereview.qt-project.org/c/qt/qtbase/+/541664 patch.
Please use this code to reproduce. qml/webengine can reproduce the same issue. Use QOpenGLWidget for convenience.
#include <QtWidgets/QApplication> #include <QtWidgets/QWidget> #include <QtOpenGLWidgets/QOpenGLWidget> #include <QtGui/QOpenGLFunctions> #include <QtGui/QWindow> class MyRhiWidget : public QOpenGLWidget, protected QOpenGLFunctions { QColor m_bgClr; public: MyRhiWidget(QColor bgClr, QWidget* parent) : QOpenGLWidget(parent) , m_bgClr(bgClr) { } void initializeGL() override { initializeOpenGLFunctions(); } void paintGL() override { glClearColor(m_bgClr.redF(), m_bgClr.greenF(), m_bgClr.blueF(), 1.0f); glClear(GL_COLOR_BUFFER_BIT); } }; int main(int argc, char** argv) { QApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); QApplication app(argc, argv); // tlw: red. QWidget tlw; tlw.resize(640, 480); tlw.setStyleSheet("QWidget { background-color: red; }"); // native: blue. QWidget native(&tlw); native.setGeometry(0, 240, 640, 240); native.setStyleSheet("QWidget { background-color: blue; }"); native.winId(); // rhi child of native: yellow MyRhiWidget rhi2(Qt::yellow, &native); rhi2.setGeometry(0, 0, 640, 240); // With https://codereview.qt-project.org/c/qt/qtbase/+/541664, the surface format will changes to: // tlw: raster // native: raster -> d3d11/metal/opengl (opengl here due to QOpenGLWidget for convenience). assert(tlw.windowHandle()->surfaceType() == QSurface::RasterSurface); assert(native.windowHandle()->surfaceType() == QSurface::OpenGLSurface); // rhi child of tlw: green MyRhiWidget rhi1(Qt::green, &tlw); rhi1.setGeometry(0, 0, 640, 240); // The surface format of tlw is expected to change to opengl. // Got: // Black // Yellow // Fail: assert(tlw.windowHandle()->surfaceType() == QSurface::OpenGLSurface); tlw.show(); return app.exec(); }
q_evaluateRhiConfigRecursive() returns false when a RHI child is native. But there is another non-native RHI child.