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 <axel.spoerl@qt.io>
(cherry picked from commit b6ca35f65372cc8519a418d6a5291cafd809f7c8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Christian Ehrlicher 2024-11-03 10:46:09 +01:00 committed by Qt Cherry-pick Bot
parent 81ba262a62
commit b63615ca6c

View File

@ -2066,6 +2066,14 @@ QSize QWindows11Style::sizeFromContents(ContentsType type, const QStyleOption *o
break;
}
#endif
case CT_ComboBox:
if (const auto *comboBoxOpt = qstyleoption_cast<const QStyleOptionComboBox *>(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;