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.

Ross
  • 46,186
  • 39
  • 120
  • 173

3 Answers3

23

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

QListView {
    outline: 0;
}
Ross
  • 46,186
  • 39
  • 120
  • 173
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.

djvg
  • 11,722
  • 5
  • 72
  • 103
i know nothing
  • 951
  • 1
  • 10
  • 27
  • 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. – djvg May 19 '23 at 14:16
2

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

QListView::item { 
    border: none;
}
Diggy.
  • 6,744
  • 3
  • 19
  • 38