Ensure QMainWindow has WA_TranslucentBackground when using unified toolbar
Otherwise the QWindow will not end up with a surface format with an alpha. This issue had been hiding in the shadows because we hard-code the backing store image format to include an alpha, but was discovered when trying to use RHI to flush the backing store, which does respect the window format. Pick-to: 6.2 6.3 Change-Id: Ie2b28ca605fc7aa1b1ed22885c8f56e76d3a0305 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>bb10
parent
8875b5a9a3
commit
1741034090
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue