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>
This commit is contained in:
Christian Ehrlicher 2019-02-02 22:03:42 +01:00
parent 568bc974d7
commit d99162754f

View File

@ -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);