summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2021-06-09 16:54:27 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2021-06-11 01:19:51 +0200
commit308845cd720969a5f3456caa8cf72023f120aecf (patch)
tree9dd114b79b87d92ad75715bf91ee9db95ae71b98 /src/widgets
parent0ec1884b243bfb0b5b97c988f45a8aa89e132574 (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 Pick-to: 6.2 Change-Id: I782d9538b695ad55d2d70b6d230f66059598768f Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets')
-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 59b0091767..d729eb631a 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -3984,6 +3984,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();
@@ -5132,8 +5140,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;