Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.2.4
-
None
Description
Qt 6.2.4 has an error that breaks use of transparency in OpenGL for MacOS.
An application using QMainWindow with QOpenGLWidget. The QMainWindow uses setUnifiedTitleAndToolBarOnMac(true). The OpenGL widget makes use of blending. When blending is used, the resulting fragments appear "bleached" (whiter than they should be, see pictures below). Somewhere the OpenGL blending is being broken.
The problem occurs starting in Qt 6.2.4. The problem is confirmed to not occur on Qt 6.2.3 or earlier.
The problem is confirmed to not occur if the call to setUnifiedTitleAndToolbarOnMac is not used.
The following commit occurred for Qt 6.2.4
diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp index 5aeea88e4e..cadb5a562f 100644 --- a/src/widgets/widgets/qmainwindow.cpp +++ b/src/widgets/widgets/qmainwindow.cpp @@ -1362,8 +1362,15 @@ void QMainWindow::setUnifiedTitleAndToolBarOnMac(bool enabled) Q_D(QMainWindow); d->useUnifiedToolBar = enabled; - createWinId(); + // The unified toolbar is drawn by the macOS style with a transparent background. + // To ensure a suitable surface format is used we need to first create backing + // QWindow so we have something to update the surface format on, and then let + // QWidget know about the translucency, which it will propagate to the surface. + setAttribute(Qt::WA_NativeWindow); + setAttribute(Qt::WA_TranslucentBackground, enabled); + + d->create(); // Create first, before querying the platform window using namespace QNativeInterface::Private; if (auto *platformWindow = dynamic_cast<QCocoaWindow*>(window()->windowHandle()->handle())) platformWindow->setContentBorderEnabled(enabled);
It is confirmed that calling setAttribute(Qt::WA_TranslucentBackground, true) without calling setUnifiedTitleAndToolbarOnMac also triggers the issue.
It appears that something about WA_TranslucentBackground changes blending context for OpenGL apps for MacOS. I've tried to figure out what this is but have not had any luck... OpenGL code in Qt is quite complicated.
I think the main takeaway is that 6.2.4 change to setUnifiedTitleAndToolbarOnMac appears breaks existing apps.
This is an example of correct display:
This is an example of the "bleached graphics". Note the transparent polygon has been changed from magenta to mostly white: