QStyleSheetStyle: fix drawing CE_MenuItem with icons
Drawing a CE_MenuItem with icons when some entries don't have an icon resulted in a misalignment of the text for the entries without an icon. Fix it by honoring QStyleOptionMenuItem::maxIconWidth which is set by QMenu depending on whether on if it's entries has an icon or not. Fixes: QTBUG-130704 Task-number: QTBUG-127536 Change-Id: I826cdce5ead5da0d1e5fdd8a5e2a6972306457b2 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> (cherry picked from commit 44634c58ceb79a63102592ec4e1b8a7399a8a660) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
92005e34e8
commit
905dfd3915
@ -3928,10 +3928,9 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
|
||||
if (qobject_cast<const QComboBox *>(w))
|
||||
drawCheckMark = false; // ignore the checkmarks provided by the QComboMenuDelegate
|
||||
#endif
|
||||
int textRectOffset = 0;
|
||||
int textRectOffset = m->maxIconWidth;
|
||||
if (!mi.icon.isNull()) {
|
||||
renderMenuItemIcon(&mi, p, w, opt->rect, subRule);
|
||||
textRectOffset = m->maxIconWidth;
|
||||
} else if (drawCheckMark) {
|
||||
const bool checkable = mi.checkType != QStyleOptionMenuItem::NotCheckable;
|
||||
const bool checked = checkable ? mi.checked : false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user