From b63615ca6ca1be031c950a3561fb5418c56472a8 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sun, 3 Nov 2024 10:46:09 +0100 Subject: [PATCH] Windows11Style: fix sizehint for QComboBox The size hint for QComboBox relied on the vista style but the painting was completely different. Therefore swith to the base windows style and add the extra margins used in the windows11 style. Fixes: QTBUG-130824 Task-number: QTBUG-11967 Change-Id: Ic533140793cdd4e640c49f6d73e9bb73bcbb83da Reviewed-by: Axel Spoerl (cherry picked from commit b6ca35f65372cc8519a418d6a5291cafd809f7c8) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/styles/modernwindows/qwindows11style.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/plugins/styles/modernwindows/qwindows11style.cpp b/src/plugins/styles/modernwindows/qwindows11style.cpp index 050ac00112a..30a524916f7 100644 --- a/src/plugins/styles/modernwindows/qwindows11style.cpp +++ b/src/plugins/styles/modernwindows/qwindows11style.cpp @@ -2066,6 +2066,14 @@ QSize QWindows11Style::sizeFromContents(ContentsType type, const QStyleOption *o break; } #endif + case CT_ComboBox: + if (const auto *comboBoxOpt = qstyleoption_cast(option)) { + contentSize = QWindowsStyle::sizeFromContents(type, option, size, widget); // don't rely on QWindowsThemeData + contentSize += QSize(4, 4); // default win11 style margins + if (comboBoxOpt->subControls & SC_ComboBoxArrow) + contentSize += QSize(8, 0); // arrow margins + } + break; default: contentSize = QWindowsVistaStyle::sizeFromContents(type, option, size, widget); break;