From 844044f37b84b1700d356e2fe27b5c6a445f88ea Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Wed, 19 Dec 2018 21:25:31 +0100 Subject: [PATCH] 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 Reviewed-by: Richard Moe Gustavsen --- src/widgets/styles/qcommonstyle.cpp | 5 +++-- 1 file 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);