diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index f84fd040e3..0437561d13 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -3282,7 +3282,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC if (customDropDownArrow) toolOpt.features &= ~(QStyleOptionToolButton::Menu | QStyleOptionToolButton::HasMenu); } - const bool customMenuIndicator = (!customDropDown && drawMenuIndicator) + const bool customMenuIndicator = (!drawDropDown && drawMenuIndicator) && hasStyleRule(w, PseudoElement_ToolButtonMenuIndicator); if (customMenuIndicator) toolOpt.features &= ~QStyleOptionToolButton::HasMenu; @@ -3354,9 +3354,9 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC } else if (drawMenuIndicator) { QRenderRule subRule = renderRule(w, opt, PseudoElement_ToolButtonMenuIndicator); - QRect r = subRule.hasGeometry() || subRule.hasPosition() - ? positionRect(w, subRule, PseudoElement_ToolButtonMenuIndicator, toolOpt.rect, toolOpt.direction) - : subRule.contentsRect(opt->rect); + // content padding does not impact the indicator, so use the original rect to + // calculate position of the sub element within the toplevel rule + QRect r = positionRect(w, rule, subRule, PseudoElement_ToolButtonMenuIndicator, opt->rect, toolOpt.direction); if (subRule.hasDrawable()) { subRule.drawRule(p, r); } else { @@ -3397,7 +3397,6 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC } subRule.drawRule(p, arrowRect); } - return; } break; diff --git a/tests/baseline/stylesheet/qss/qtoolbutton/menuButton_subcontrol_padding.qss b/tests/baseline/stylesheet/qss/qtoolbutton/menuButton_subcontrol_padding.qss new file mode 100644 index 0000000000..44e67671f0 --- /dev/null +++ b/tests/baseline/stylesheet/qss/qtoolbutton/menuButton_subcontrol_padding.qss @@ -0,0 +1,12 @@ +QToolButton { + border: 5px solid #9e9e9e; + background: #ffffff; + padding-top: 8px; + padding-bottom: 8px; +} +QToolButton[popupMode=InstantPopup] { + padding-right: 75px; +} +QToolButton::menu-indicator { + subcontrol-position: right; +};