From fd372f3866acecf31f69992d6d99fc7c965018bb Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 9 Jan 2013 12:54:08 +0100 Subject: [PATCH] Update translucency correctly in QtWidgets. Fixes breakage introduced by cdc436ebe625153c626784a15cb224556fca3728 . Top level widgets with translucent backgrounds were invisible since opacity was set to 0. Task-number: QTBUG-28531 Change-Id: I97058ac1b971422f3bda3a5ffed479ec55bfe5d4 Reviewed-by: Joerg Bornemann --- src/widgets/kernel/qwidget.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 38d3198f2f..e0b1236679 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -2080,8 +2080,15 @@ void QWidgetPrivate::setOpaque(bool opaque) void QWidgetPrivate::updateIsTranslucent() { Q_Q(QWidget); - if (QWindow *window = q->windowHandle()) - window->setOpacity(isOpaque ? qreal(1.0) : qreal(0.0)); + if (QWindow *window = q->windowHandle()) { + QSurfaceFormat format = window->format(); + const int oldAlpha = format.alphaBufferSize(); + const int newAlpha = q->testAttribute(Qt::WA_TranslucentBackground)? 8 : 0; + if (oldAlpha != newAlpha) { + format.setAlphaBufferSize(newAlpha); + window->setFormat(format); + } + } } static inline void fillRegion(QPainter *painter, const QRegion &rgn, const QBrush &brush)