summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2019-02-02 22:03:42 +0100
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2019-02-13 05:55:20 +0000
commitd99162754f225ca98318e96184e80a57c33fa1ed (patch)
treed1464b26e40e8448ea97e3dd4af1b942483728aa /src/widgets
parent568bc974d7d89f8d12bc4877c59e4291fe582e8b (diff)
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 <frederik.gladhorn@qt.io> Reviewed-by: Vitaly Fanaskov <vitaly.fanaskov@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp5
1 files changed, 5 insertions, 0 deletions
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);