Windows11Style: don't set minimum width for QAbstractSpinBox

There is no need to set a minimum width for QAbstractSpinBox in
QWindows11Style::polish() as this might override the user preferences.
Also the minimum size handling is now properly done within
sizeFromContents().

Pick-to: 6.9 6.8
Change-Id: Ibc1fd7a6f862fc85e3739025b9de581aa235d74c
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
This commit is contained in:
Christian Ehrlicher 2025-01-19 17:55:37 +01:00
parent 9574e8cbef
commit 2ec4c28470

View File

@ -34,7 +34,6 @@ QT_BEGIN_NAMESPACE
static constexpr int topLevelRoundingRadius = 8; //Radius for toplevel items like popups for round corners
static constexpr int secondLevelRoundingRadius = 4; //Radius for second level items like hovered menu item round corners
static constexpr QLatin1StringView originalWidthProperty("_q_windows11_style_original_width");
enum WINUI3Color {
subtleHighlightColor, //Subtle highlight based on alpha used for hovered elements
@ -2173,13 +2172,6 @@ void QWindows11Style::polish(QWidget* widget)
pal.setColor(QPalette::ButtonText, pal.text().color());
pal.setColor(QPalette::BrightText, pal.text().color());
widget->setPalette(pal);
} else if (widget->inherits("QAbstractSpinBox")) {
const int minWidth = 2 * 24 + 40;
const int originalWidth = widget->size().width();
if (originalWidth < minWidth) {
widget->resize(minWidth, widget->size().height());
widget->setProperty(originalWidthProperty.constData(), originalWidth);
}
} else if (widget->inherits("QAbstractButton") || widget->inherits("QToolButton")) {
widget->setAutoFillBackground(false);
auto pal = widget->palette();
@ -2230,13 +2222,6 @@ void QWindows11Style::unpolish(QWidget *widget)
scrollarea->viewport()->setPalette(pal);
scrollarea->viewport()->setProperty("_q_original_background_palette", QVariant());
}
if (widget->inherits("QAbstractSpinBox")) {
const QVariant originalWidth = widget->property(originalWidthProperty.constData());
if (originalWidth.isValid()) {
widget->resize(originalWidth.toInt(), widget->size().height());
widget->setProperty(originalWidthProperty.constData(), QVariant());
}
}
}
/*