From e555c03a4255bb4109a4b55d38561297ce8a2d2e Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Mon, 10 Oct 2016 16:16:24 +0300 Subject: Style sheets: Include margin while calculating QHeaderview section size Align with QCommonstyle QHeaderview section size calculation. Change-Id: I4c11e1881f48850ace3bdbb3c96f999cc298c91e Task-number: QTBUG-56457 Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: Christian Ehrlicher --- src/widgets/styles/qstylesheetstyle.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/widgets/styles/qstylesheetstyle.cpp') diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index e12aeb900b..c4fc353803 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -4983,11 +4983,13 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op if (!subRule.hasGeometry()) { QSize nativeContentsSize; bool nullIcon = hdr->icon.isNull(); + const int margin = pixelMetric(QStyle::PM_HeaderMargin, hdr, w); int iconSize = nullIcon ? 0 : pixelMetric(QStyle::PM_SmallIconSize, hdr, w); const QSize txt = subRule.hasFont ? QFontMetrics(subRule.font).size(0, hdr->text) : hdr->fontMetrics.size(0, hdr->text); - nativeContentsSize.setHeight(qMax(iconSize, txt.height())); - nativeContentsSize.setWidth(iconSize + txt.width()); + nativeContentsSize.setHeight(margin + qMax(iconSize, txt.height()) + margin); + nativeContentsSize.setWidth((nullIcon ? 0 : margin) + iconSize + + (hdr->text.isNull() ? 0 : margin) + txt.width() + margin); sz = sz.expandedTo(nativeContentsSize); } return subRule.size(sz); -- cgit v1.2.3