I have a QTreeView
with a stylesheet defining the selection. However, when I use the "fusion" style, there is an additional blue selection rectangle over the decoration:
I've tried using show-decoration-selected: 0;
in the style sheet, as well as setting setAllColumnsShowFocus(false);
, but can't get it to go away.
Is there some way to disable or restyle the part of the selection that covers the decorator?
For reference, here's the stylesheet:
QTreeView, QListView, QToolBar, QTableView
{
show-decoration-selected: 0;
background: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,
stop: 0 #797979, stop: 0.2 #CCCCCC,
stop: 1.0 #FFFFFF);
alternate-background-color: #333333;
background-image: url(:/metal_scratched);
outline: 0; /* removes focus rectangle*/
}
QTreeView::section, QListView::section, QToolBar::section, QTableView::section
{
border: 1px solid black;
}
QTreeView::item:hover:enabled, QListView::item:hover:enabled, QToolBar::item:hover:enabled, QTableView::item:hover:enabled
{
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 transparent, stop: 0.4 rgba(150,150,150,0.5),
stop: 0.5 rgba(125,125,125,0.5), stop: 1.0 transparent);
border-color: #B0B0B0;
}
QTreeView::item:hover:!enabled, QListView:disabled:hover, QToolBar:disabled:hover, QTableView:disabled:hover
{
/* don't highlight */
}
QTreeView::item:selected, QListView::item:selected, QToolBar::item:selected, QTableView::item:selected
{
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 transparent, stop: 0.4 rgba(75,75,75,0.5),
stop: 0.5 rgba(50,50,50,0.5), stop: 1.0 transparent);
border-color: #5A5A5A;
color: white;
}
The blue artifact can be removed by overriding the default selection color in the style sheet. Leaving everything else the same (importantly, continuing to define a new selection color using QTreeView::item:selected
), adding the following property will remove the undesired behavior.
QTreeView
{
// everything else the same
selection-background-color: transparent;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With