summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles
diff options
context:
space:
mode:
authorXiang Xiaojun <xiangxiaojun@uniontech.com>2020-11-24 19:00:52 +0800
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-11-26 14:43:20 +0100
commit6269438af95bbd988ead08829fa3bc9dc25891e8 (patch)
tree8976acd71ce797b26bf1762e907da9f3161c5f65 /src/widgets/styles
parent5b93f6cae692363ab03b0c9b0ae8efd0bb4ef499 (diff)
QPushButton: fix support of style sheet rule for text alignment
Fixes: QTBUG-86857 Pick-to: 5.15 6.0 Change-Id: I7e3e2b5323b1e46f572cacfddae20cb6e7882a47 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/widgets/styles')
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index a4d41566ee..bbfee0c662 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))