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>
This commit is contained in:
parent
0ec1884b24
commit
308845cd72
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user