diff options
author | Andy Shaw <andy.shaw@qt.io> | 2020-08-17 14:53:39 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2020-08-19 12:46:38 +0000 |
commit | 5d1da325afb099487bff0fbfc0df33f791ec6b8e (patch) | |
tree | 8a6bf8c12dfb7f7d8c4a4961d9eb52ecac69cb82 /src | |
parent | f6a57817798a1ade1eb643d0c532c98997f9d65a (diff) | |
download | qtbase-5d1da325afb099487bff0fbfc0df33f791ec6b8e.tar.gz |
Don't crop the icon when it is aligned to the left
When we use double the icon spacing then the area for the pushbutton is
not long enough, so in order to account for the gap inbetween then just
use half of the icon spacing when positioning the text as it only has
spacing on one side of the icon to it.
Change-Id: Ib3fe0037835b67efda0fc274421f976ccc98eb06
Fixes: QTBUG-85723
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit c3f74bdc3ffdc69dce17530f9fafb2d6d15b746b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/widgets/styles/qcommonstyle.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 8317a30f36..5e37b81faf 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -1379,7 +1379,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, int iconSpacing = 4;//### 4 is currently hardcoded in QPushButton::sizeHint() if (!button->text.isEmpty()) { int textWidth = button->fontMetrics.boundingRect(opt->rect, tf, button->text).width(); - labelWidth += (textWidth + iconSpacing * 2); + labelWidth += (textWidth + iconSpacing); } QRect iconRect = QRect(textRect.x() + (textRect.width() - labelWidth) / 2, @@ -1390,10 +1390,10 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, if (button->direction == Qt::RightToLeft) { tf |= Qt::AlignRight; - textRect.setRight(iconRect.left() - iconSpacing); + textRect.setRight(iconRect.left() - iconSpacing / 2); } else { tf |= Qt::AlignLeft; //left align, we adjust the text-rect instead - textRect.setLeft(iconRect.left() + iconRect.width() + iconSpacing); + textRect.setLeft(iconRect.left() + iconRect.width() + iconSpacing / 2); } if (button->state & (State_On | State_Sunken)) |