summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2021-06-09 16:54:27 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-06-10 23:20:02 +0000
commit0f6a9fdc2f1a20d590e51bbc3eee93c2ffeb1850 (patch)
tree69e753ea5ce87c702e066e9469485580abaf7706 /src
parenta3e99e8e008be0961aa859cfefa9b389e2866e6b (diff)
In headers with only the arrow styled, prevent overlapping with text
A style sheet that styles only the header arrow, but not the header section or label, resulted in an overlapped text and header if the text was also right aligned. To prevent this, add the space required by the arrow to the size calculation, and shorten the space accordingly before rendering the right-aligned label. Make corresponding adjustments to vertical headers with bottom-aligned labels. Fixes: QTBUG-84117 Change-Id: I782d9538b695ad55d2d70b6d230f66059598768f Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> (cherry picked from commit 308845cd720969a5f3456caa8cf72023f120aecf) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index 16db14e18e..b02e4011b2 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -4044,6 +4044,14 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
QStyleOptionHeader hdr(*header);
QRenderRule subRule = renderRule(w, opt, PseudoElement_HeaderViewSection);
+ if (hasStyleRule(w, PseudoElement_HeaderViewUpArrow)
+ || hasStyleRule(w, PseudoElement_HeaderViewDownArrow)) {
+ const QRect arrowRect = subElementRect(SE_HeaderArrow, opt, w);
+ if (hdr.orientation == Qt::Horizontal)
+ hdr.rect.setWidth(hdr.rect.width() - arrowRect.width());
+ else
+ hdr.rect.setHeight(hdr.rect.height() - arrowRect.height());
+ }
subRule.configurePalette(&hdr.palette, QPalette::ButtonText, QPalette::Button);
if (subRule.hasFont) {
QFont oldFont = p->font();
@@ -5203,8 +5211,17 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op
}
return subRule.size(sz);
}
- return subRule.baseStyleCanDraw() ? baseStyle()->sizeFromContents(ct, opt, sz, w)
- : QWindowsStyle::sizeFromContents(ct, opt, sz, w);
+ sz = subRule.baseStyleCanDraw() ? baseStyle()->sizeFromContents(ct, opt, sz, w)
+ : QWindowsStyle::sizeFromContents(ct, opt, sz, w);
+ if (hasStyleRule(w, PseudoElement_HeaderViewDownArrow)
+ || hasStyleRule(w, PseudoElement_HeaderViewUpArrow)) {
+ const QRect arrowRect = subElementRect(SE_HeaderArrow, opt, w);
+ if (hdr->orientation == Qt::Horizontal)
+ sz.rwidth() += arrowRect.width();
+ else
+ sz.rheight() += arrowRect.height();
+ }
+ return sz;
}
}
break;