Skip rendering border for the decoration area of the tree view
The tree view widget draws a border for both the decoration area and the text that accompanies the first column whenever any background color is set to the row. The background color set for the row shouldn't affect the border of the decoration area. This patch fixes that issue by handling the background draw for the decoration area separately by drawing the background for the decoration area without considering the configured borders. Fixes: QTBUG-122778 Pick-to: 6.7 Change-Id: I308998a29d16c910a5370633e5bff18418c96a44 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 3ca615d9735f7ddb8e2ae5c13e5effd419a56300) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
c6dd4856ca
commit
755f964364
@ -1821,7 +1821,10 @@ void QTreeView::drawRow(QPainter *painter, const QStyleOptionViewItem &option,
|
||||
const bool oldShowDecorationSelected = opt.showDecorationSelected;
|
||||
opt.showDecorationSelected = style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected,
|
||||
&opt, this);
|
||||
opt.features |= QStyleOptionViewItem::HasDecoration;
|
||||
opt.rect = branches;
|
||||
style()->drawPrimitive(QStyle::PE_PanelItemViewRow, &opt, painter, this);
|
||||
opt.features &= ~QStyleOptionViewItem::HasDecoration;
|
||||
|
||||
// draw background of the item (only alternate row). rest of the background
|
||||
// is provided by the delegate
|
||||
|
@ -4844,8 +4844,24 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op
|
||||
// only indirectly through the background of the item. To get the
|
||||
// same background for all parts drawn by QTreeView, we have to
|
||||
// use the background rule for the item here.
|
||||
if (renderRule(w, opt, PseudoElement_ViewItem).hasBackground())
|
||||
if (renderRule(w, opt, PseudoElement_ViewItem).hasBackground()) {
|
||||
pseudoElement = PseudoElement_ViewItem;
|
||||
// Skip border for the branch and draw only the brackground
|
||||
if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
|
||||
QRenderRule rule = renderRule(w, opt, PseudoElement_ViewItem);
|
||||
if (vopt->features & QStyleOptionViewItem::HasDecoration &&
|
||||
(vopt->viewItemPosition == QStyleOptionViewItem::Beginning ||
|
||||
vopt->viewItemPosition == QStyleOptionViewItem::OnlyOne) && rule.hasBorder()) {
|
||||
if (rule.hasDrawable()) {
|
||||
rule.drawBackground(p, rect);
|
||||
rule.drawImage(p, rule.contentsRect(rect));
|
||||
} else {
|
||||
baseStyle()->drawPrimitive(pe, opt, p, w);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PE_PanelItemViewItem:
|
||||
pseudoElement = PseudoElement_ViewItem;
|
||||
|
@ -0,0 +1,3 @@
|
||||
QTreeWidget::item {
|
||||
border: 1px solid #32ff44;
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
QTreeWidget::item {
|
||||
border: 1px solid #32ff44;
|
||||
background-color: transparent;
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
QTreeWidget::item {
|
||||
border: 1px solid #32ff44;
|
||||
background-color: orange;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user