diff options
author | Peng Wu <peng.wu@intopalo.com> | 2016-10-10 16:16:24 +0300 |
---|---|---|
committer | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2018-04-22 19:30:20 +0000 |
commit | e555c03a4255bb4109a4b55d38561297ce8a2d2e (patch) | |
tree | 7d0320b00876ce49fcd10423aaa21b11c9479f9d /src/widgets/styles | |
parent | 070aec28e6e218c4f5fc2e3bb480cfc7684728d2 (diff) |
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) <ogoffart@woboq.com>
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Diffstat (limited to 'src/widgets/styles')
-rw-r--r-- | src/widgets/styles/qstylesheetstyle.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
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); |