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.

Pick-to: 6.8
Fixes: QTBUG-130824
Task-number: QTBUG-11967
Change-Id: Ic533140793cdd4e640c49f6d73e9bb73bcbb83da
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
This commit is contained in:
Christian Ehrlicher 2024-11-03 10:46:09 +01:00
parent 814e4e1cbe
commit b6ca35f653

View File

@ -2098,6 +2098,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;