From 2ec4c28470de115c16944653a5d4f6209452d56c Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sun, 19 Jan 2025 17:55:37 +0100 Subject: [PATCH] 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 --- .../styles/modernwindows/qwindows11style.cpp | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/plugins/styles/modernwindows/qwindows11style.cpp b/src/plugins/styles/modernwindows/qwindows11style.cpp index f3e168f0d3f..04245979dd6 100644 --- a/src/plugins/styles/modernwindows/qwindows11style.cpp +++ b/src/plugins/styles/modernwindows/qwindows11style.cpp @@ -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()); - } - } } /*