Update visible window's alpha when toggling WA_TranslucentBackground
QWidgetPrivate::updateIsTranslucent sets the surface format of the window with the alpha based on the translucency attribute, so we need to call this function when the attribute value changes. The test can confirm that the window's requested surface format has changed, we can't rely on what is actually set, and don't have to rely on hard-coded values like 8bit alpha. While WA_NoSystemBackground needs to be set for WA_TranslucentBackground to have an effect, we can't clear the attribute when clearing translucency (as it might have been set explicitly). Change-Id: I238d6930b7e0488397467a4e035b5f530566a1ff Fixes: QTBUG-60822 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>bb10
parent
1eeab2d27f
commit
555661b625
|
|
@ -11474,10 +11474,9 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
|
|||
}
|
||||
break;
|
||||
case Qt::WA_TranslucentBackground:
|
||||
if (on) {
|
||||
if (on)
|
||||
setAttribute(Qt::WA_NoSystemBackground);
|
||||
d->updateIsTranslucent();
|
||||
}
|
||||
d->updateIsTranslucent();
|
||||
|
||||
break;
|
||||
case Qt::WA_AcceptTouchEvents:
|
||||
|
|
|
|||
|
|
@ -8855,6 +8855,12 @@ void tst_QWidget::translucentWidget()
|
|||
QEXPECT_FAIL("", "WinRT: This fails. QTBUG-68297.", Abort);
|
||||
QCOMPARE(actual.size(),expected.size());
|
||||
QCOMPARE(actual,expected);
|
||||
|
||||
const QWindow *window = label.windowHandle();
|
||||
const QSurfaceFormat translucentFormat = window->requestedFormat();
|
||||
label.setAttribute(Qt::WA_TranslucentBackground, false);
|
||||
const QSurfaceFormat opaqueFormat = window->requestedFormat();
|
||||
QVERIFY(translucentFormat != opaqueFormat);
|
||||
}
|
||||
|
||||
class MaskResizeTestWidget : public QWidget
|
||||
|
|
|
|||
Loading…
Reference in New Issue