From d99162754f225ca98318e96184e80a57c33fa1ed Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sat, 2 Feb 2019 22:03:42 +0100 Subject: QStyleSheet/QToolbox: don't overlap text and icon When an icon was specified with a style sheet, the content rect for the toolbox label was not adjusted which results in an overlapping of the text and the icon. Fix it by adjusting the rect used by drawing the label when an icon is specified with a style sheet. Fixes: QTBUG-40871 Change-Id: I088b319e6355d78066d0bc4472882a5d9a599091 Reviewed-by: Frederik Gladhorn Reviewed-by: Vitaly Fanaskov --- src/widgets/styles/qstylesheetstyle.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index e73d019408..c0f0321fce 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -4089,6 +4089,11 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q if (subRule.hasFont) p->setFont(subRule.font); boxCopy.rect = subRule.contentsRect(opt->rect); + if (subRule.hasImage()) { + // the image is already drawn with CE_ToolBoxTabShape, adjust rect here + const int iconExtent = proxy()->pixelMetric(QStyle::PM_SmallIconSize, box, w); + boxCopy.rect.setLeft(boxCopy.rect.left() + iconExtent); + } QWindowsStyle::drawControl(ce, &boxCopy, p , w); if (subRule.hasFont) p->setFont(oldFont); -- cgit v1.2.3