Get rid of Qt's dotted outline on QListView items
Asked Answered
G

3

14

I'm trying to remove the dotted border on the text in this QListView::item using stylesheets:

QListView with dotted outline shown on selected item

I've tried variations of border: 0 and show-decoration-selected: 0 on QListView, QListView::item and QListView::item::text to no effect.

I'm using PyQt, but I believe the stylesheet rules are the same as in the C++ libraries.

Girondist answered 5/4, 2013 at 9:30 Comment(0)
G
23

After some more testing, I found that the following stylesheet works:

QListView {
    outline: 0;
}
Girondist answered 5/4, 2013 at 10:12 Comment(0)
F
4

Setting outline: 0; in the stylesheet doesn't work for me (anymore?). The only solution I could find was to set the ListView's FocusPolicy to Qt::NoFocus, which comes with obvious drawbacks.

Finegrained answered 19/1, 2018 at 7:53 Comment(1)
One possible reason for outline: 0 not working in a QListWidget is if you set it on the QListWidget::item instead of the QListWidget itself. Not sure if this also holds for the QListView case.Toole
P
2

Setting the border to none seems to have done the trick for me.

QListView::item { 
    border: none;
}
Peisch answered 7/5, 2019 at 9:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.