StyleSheet: Use rule for ComboBox in embedded QLineEdit

An editable combobox uses an embedded QLineEdit as an implementation
detail. That lineedit should use the rules that are set for the combobox
to render itself, similar to what was already implemented for the lineedit
used in a QAbstractSpinBox.

The containerWidget helper function provides the logic for identifying
the container of the rendered widget, returning the QAbstractSpinBox or
the QComboBox for an embedded QLineEdit. Use that method rather than
duplicating the logic.

Pick-to: 6.2 6.1 5.15
Fixes: QTBUG-95631
Change-Id: I50bc92a62715608b11c2c923f8f9215f56bfd15e
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
This commit is contained in:
Volker Hilsheimer 2021-08-10 14:58:39 +02:00
parent a7b1aaa98b
commit adafa5ee1f

View File

@ -4582,14 +4582,13 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op
case PE_PanelLineEdit:
if (const QStyleOptionFrame *frm = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
#if QT_CONFIG(spinbox)
if (w && qobject_cast<const QAbstractSpinBox *>(w->parentWidget())) {
QRenderRule spinboxRule = renderRule(w->parentWidget(), opt);
if (!spinboxRule.hasNativeBorder() || !spinboxRule.baseStyleCanDraw())
if (QWidget *container = containerWidget(w); container != w) {
QRenderRule containerRule = renderRule(container, opt);
if (!containerRule.hasNativeBorder() || !containerRule.baseStyleCanDraw())
return;
rule = spinboxRule;
rule = containerRule;
}
#endif
if (rule.hasNativeBorder()) {
QStyleOptionFrame frmOpt(*frm);
rule.configurePalette(&frmOpt.palette, QPalette::Text, QPalette::Base);