UI Error: QOpenGLContext::makeCurrent() called with non-opengl surface after upgrading to QT 6

Hello, my configuration like this:

Ubuntu 24.04
OCC 7.8.1
QT 6.4.2

I have a QWindow which contains a QTabWidget, and this TabWidget has two children widgets

First tab simply associates with a QPushButton
Second tab associates with an OccQtViewer which is inherited from QOpenGLWidget, and contains all OCC related stuffs like attached picture: messed_up_ui.png

After switching from first tab to second tab, the UI get messed up and the tabs won't response to Clicking event anymore and at the same time, below warning messages got printed out:

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

And I have attached all related source code in this post, and

Under Windows, same code works fine with Qt_6
Under linux, it works fine with Qt_5, but with Qt_6, it will print out above warnings.

I found a similar issue got reported here:

https://github.com/MythTV/mythtv/issues/754

And tried the suggestion of it to setSurfaceType like this:

QWidget* native = nativeParentWidget();
windowHandle()->setSurfaceType(QWindow::OpenGLSurface);
if (native && native->windowHandle())
native->windowHandle()->setSurfaceType(QWindow::OpenGLSurface);

No lucky, this may be compatibility problem,
but I am not sure whether this problem comes from OCC or QT_6(under linux),

Would you please help to fix this issue.

AlexLuya's picture

After upgrading to Qt 6.5.3, this problem gone