summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2018-12-19 21:25:31 +0100
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2018-12-24 11:59:16 +0000
commit844044f37b84b1700d356e2fe27b5c6a445f88ea (patch)
tree430cd6083bb1c945dc7e240b65b643e06b514365 /src/widgets/styles
parentaece0a13569737bbcced0e73c0e0b12863e2cf1f (diff)
QTabWidget: properly horizontally align tab icon
When an icon used for a QTabWidget is smaller than the default size, it was not properly aligned horizontally although it was done for the vertical alignment. Therefore also align it horizontally to be consistent. Fixes: QTBUG-38108 Change-Id: I0e2e3af7ead699f2834aed1d8b67cbe775c897af Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets/styles')
-rw-r--r--src/widgets/styles/qcommonstyle.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index 01c69f1152..b146cb1183 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -1186,8 +1186,9 @@ void QCommonStylePrivate::tabLayout(const QStyleOptionTab *opt, const QWidget *w
// High-dpi icons do not need adjustment; make sure tabIconSize is not larger than iconSize
tabIconSize = QSize(qMin(tabIconSize.width(), iconSize.width()), qMin(tabIconSize.height(), iconSize.height()));
- *iconRect = QRect(tr.left(), tr.center().y() - tabIconSize.height() / 2,
- tabIconSize.width(), tabIconSize.height());
+ const int offsetX = (iconSize.width() - tabIconSize.width()) / 2;
+ *iconRect = QRect(tr.left() + offsetX, tr.center().y() - tabIconSize.height() / 2,
+ tabIconSize.width(), tabIconSize.height());
if (!verticalTabs)
*iconRect = proxyStyle->visualRect(opt->direction, opt->rect, *iconRect);
tr.setLeft(tr.left() + tabIconSize.width() + 4);