Evaluate TranslucentBackground when (re)creating the window

The problem is reported in combination with the new 6.4 way of
handling texture-based widgets, but this looks like something that has
always been missing:

Setting WA_TranslucentBackground changes the QWidgetWindow's format,
and this is done upon calling setAttribute(). That's good for most
cases, but the changes to the QWindow's format are lost when the
window is destroyed and then the widget gets another window
later. This is not that common, but can happen.

For example, if a top-level widget is parented under something else,
and then later it is parented to null again, so that it is toplevel
once again, background transparency can be lost because nothing
re-evaluates the WA_TranslucentBackground flag after the initial
setAttribute(), and so the widget's second QWidgetWindow is not set up
accordingly (because this new QWindow may not have alpha specified in
the QSurfaceFormat which may or may not be a problem, depending on the
platform / windowing system)

The simple solution is to evaluate the attribute not just when setting
it, but also when a new QWidgetWindow is created for the widget.

Fixes: QTBUG-104952
Pick-to: 6.4
Change-Id: I92746caea5561544f90395d5473ac28d43143924
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Laszlo Agocs 2022-07-14 10:43:49 +02:00
parent e8e584090b
commit 856bb38eaf

View File

@ -1398,6 +1398,8 @@ void QWidgetPrivate::createTLSysExtra()
#endif #endif
if (isTipLabel || isAlphaWidget || q->inherits("QRollEffect")) if (isTipLabel || isAlphaWidget || q->inherits("QRollEffect"))
qt_window_private(extra->topextra->window)->setAutomaticPositionAndResizeEnabled(false); qt_window_private(extra->topextra->window)->setAutomaticPositionAndResizeEnabled(false);
updateIsTranslucent();
} }
} }