如何在 Qt QListView 或 QListWidget 中隐藏选择 rectangle/dotted 行?

How to hide the selection rectangle/dotted lines in a Qt QListView or QListWidget?

在我的界面中,我不想在当前选中的项目周围显示虚线 lines/rectangle。

我在网上看到没有办法用样式表来做到这一点,最好的方法是创建一个新的 class 来覆盖 paint 方法,如 this link 中所建议的那样。

但是,如果不需要创建一个完整的其他 class。

事实证明,在许多情况下 可能的,只需按照建议 here.[=13] 将 QListWidget::focusPolicy 设置为 NoFocus =]