From 969fbfb89b9e251c12ff6ec4ed18deaacbd05503 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Tue, 1 Apr 2025 21:49:40 +0200 Subject: [PATCH] Windows11Style: Disable shadow for QComboBox inside QGraphicsProxyWidget A QGraphicsEffect is not rendered inside a QGraphicsView so we must not set it on a QComboBoxPrivateContainer. We have to do some checks for it when a stylesheet is set as polish() is then called before the proxy widget is set on the QComboBoxPrivateContainer. But luckily QComboBox has the proxy widget already set so do the check there. Pick-to: 6.8 Fixes: QTBUG-135340 Task-number: QTBUG-128916 Task-number: QTBUG-128329 Change-Id: I2426701f3aa44a2eb14b66846628dbb9cd16dc9f Reviewed-by: Axel Spoerl (cherry picked from commit 847c0bf07695942271f9a0cf2b3eb63fa19c7d72) Reviewed-by: Qt Cherry-pick Bot --- .../styles/modernwindows/qwindows11style.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/plugins/styles/modernwindows/qwindows11style.cpp b/src/plugins/styles/modernwindows/qwindows11style.cpp index 7566e00fd9e..e42a12218f5 100644 --- a/src/plugins/styles/modernwindows/qwindows11style.cpp +++ b/src/plugins/styles/modernwindows/qwindows11style.cpp @@ -2211,13 +2211,17 @@ void QWindows11Style::polish(QWidget* widget) auto pal = widget->palette(); pal.setColor(widget->backgroundRole(), Qt::transparent); widget->setPalette(pal); - if (!isScrollBar - && widget->graphicsProxyWidget() == nullptr) { // for menus and combobox containers... - QGraphicsDropShadowEffect* dropshadow = new QGraphicsDropShadowEffect(widget); - dropshadow->setBlurRadius(3); - dropshadow->setXOffset(3); - dropshadow->setYOffset(3); - widget->setGraphicsEffect(dropshadow); + if (!isScrollBar) { + bool inGraphicsView = widget->graphicsProxyWidget() != nullptr; + if (!inGraphicsView && comboBoxContainer && comboBoxContainer->parentWidget()) + inGraphicsView = comboBoxContainer->parentWidget()->graphicsProxyWidget() != nullptr; + if (!inGraphicsView) { // for menus and combobox containers... + QGraphicsDropShadowEffect *dropshadow = new QGraphicsDropShadowEffect(widget); + dropshadow->setBlurRadius(3); + dropshadow->setXOffset(3); + dropshadow->setYOffset(3); + widget->setGraphicsEffect(dropshadow); + } } } else if (QComboBox* cb = qobject_cast(widget)) { if (cb->isEditable()) {