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 <axel.spoerl@qt.io>
(cherry picked from commit 847c0bf07695942271f9a0cf2b3eb63fa19c7d72)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Christian Ehrlicher 2025-04-01 21:49:40 +02:00 committed by Qt Cherry-pick Bot
parent 40fa39ba83
commit 969fbfb89b

View File

@ -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<QComboBox*>(widget)) {
if (cb->isEditable()) {