From cfd2cc91fdae40d8e1eddfc2f9ff2585a0b708e4 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Thu, 20 Jun 2019 16:53:24 +0200 Subject: [PATCH] Always fill the background of a tabbed QMdiSubWindow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QMacStyle polishes QMdiSubWindows to have autoFillBackground set to false. If the QMdiSubWindow's widget also doesn't fill the background (like QLabel), then nobody fills the window in a tabbed QMdiArea, and the other subwindows show through. This change makes sure that all pixels are painted in that situations, using the styled frame. Fixes: QTBUG-76214 Change-Id: Iae025d15d36a8bc0d0c5838ac43c9d54944bcc83 Reviewed-by: Tor Arne Vestbø --- src/widgets/widgets/qmdisubwindow.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp index 794674c427..e9511f944f 100644 --- a/src/widgets/widgets/qmdisubwindow.cpp +++ b/src/widgets/widgets/qmdisubwindow.cpp @@ -3140,8 +3140,6 @@ void QMdiSubWindow::paintEvent(QPaintEvent *paintEvent) } Q_D(QMdiSubWindow); - if (isMaximized() && !d->drawTitleBarWhenMaximized()) - return; if (d->resizeTimerId != -1) { // Only update the style option rect and the window title. @@ -3161,6 +3159,17 @@ void QMdiSubWindow::paintEvent(QPaintEvent *paintEvent) } QStylePainter painter(this); + QStyleOptionFrame frameOptions; + frameOptions.initFrom(this); + frameOptions.state.setFlag(QStyle::State_Active, d->isActive); + if (isMaximized() && !d->drawTitleBarWhenMaximized()) { + if (!autoFillBackground() && (!widget() || !qt_widget_private(widget())->isOpaque)) { + // make sure we paint all pixels of a maximized QMdiSubWindow if no-one else does + painter.drawPrimitive(QStyle::PE_FrameWindow, frameOptions); + } + return; + } + if (!d->windowTitle.isEmpty()) painter.setFont(d->font); painter.drawComplexControl(QStyle::CC_TitleBar, d->cachedStyleOptions); @@ -3168,10 +3177,7 @@ void QMdiSubWindow::paintEvent(QPaintEvent *paintEvent) if (isMinimized() && !d->hasBorder(d->cachedStyleOptions)) return; - QStyleOptionFrame frameOptions; - frameOptions.initFrom(this); frameOptions.lineWidth = style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, this); - frameOptions.state.setFlag(QStyle::State_Active, d->isActive); // ### Ensure that we do not require setting the cliprect for 4.4 if (!isMinimized() && !d->hasBorder(d->cachedStyleOptions))