diff options
author | Xiang Xiaojun <xiangxiaojun@uniontech.com> | 2020-11-24 19:00:52 +0800 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2020-12-04 06:36:22 +0000 |
commit | cc785b9b68d1b3b848be67e672dea91ee5715b7b (patch) | |
tree | 32a81af7116631be3009c9f48dd98a4acc611a07 /src/widgets | |
parent | cfa83bbc15aa4a8e84a9fd628cbf0b9b61622b0c (diff) |
QPushButton: fix support of style sheet rule for text alignment
Fixes: QTBUG-86857
Change-Id: I7e3e2b5323b1e46f572cacfddae20cb6e7882a47
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 6269438af95bbd988ead08829fa3bc9dc25891e8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/styles/qstylesheetstyle.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 2e5ee67952..142366d2e3 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -3555,8 +3555,8 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q const uint horizontalAlignMask = Qt::AlignHCenter | Qt::AlignLeft | Qt::AlignRight; const uint verticalAlignMask = Qt::AlignVCenter | Qt::AlignTop | Qt::AlignLeft; - if (rule.hasPosition() && rule.position()->textAlignment != 0) { - Qt::Alignment textAlignment = rule.position()->textAlignment; + const Qt::Alignment textAlignment = rule.position()->textAlignment; + if (rule.hasPosition() && textAlignment != 0) { tf |= (textAlignment & verticalAlignMask) ? (textAlignment & verticalAlignMask) : Qt::AlignVCenter; tf |= (textAlignment & horizontalAlignMask) ? (textAlignment & horizontalAlignMask) : Qt::AlignHCenter; if (!styleHint(SH_UnderlineShortcut, button, w)) @@ -3615,6 +3615,8 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q iconRect.translate(pixelMetric(PM_ButtonShiftHorizontal, opt, w), pixelMetric(PM_ButtonShiftVertical, opt, w)); p->drawPixmap(iconRect, pixmap); + }else { + tf |= textAlignment; } if (button->state & (State_On | State_Sunken)) |