QListView、QListWidget控件样式
- 常用属性

- 子控件

- 伪状态

QSS示例
-
新建一个 QMainWindow 窗口,拖入 QListView 和 QListWidget 控件:

-
如下所示,当对 QListView 控件样式进行设置时 QListWidget 控件的样式也一样改变,因为 QListWidget 是 QListView的子类
QListView{ color: white; font-size: 15px; font-weight: bold; background-color: blue; show-decoration-selected: 1; /*选择整行而不是只有文字部分*/ /*交替变换颜色*/ alternate-background-color: red; /*去除选中的虚线框*/ outline: none; } QListView::item:alternate{ background-color: gray; /*会覆盖之前的交替变换颜色*/ }
-
如下所示。
QListView{ color: white; font-size: 15px; font-weight: bold; background-color: blue; show-decoration-selected: 1; /*选择整行而不是只有文字部分*/ /*交替变换颜色*/ alternate-background-color: red; /*去除选中的虚线框*/ outline: none; } QListView::item:alternate{ background-color: gray; /*会覆盖之前的交替变换颜色*/ } /*被选择项*/ QListView::item:selected { border: 1px solid white; } /*选中且窗口有焦点*/ QListView::item:selected:active { background-color: red; } /*被选择且窗口没有焦点了*/ QListView::item:selected:!active { background-color: yellow; } /*鼠标经过项*/ QListView::item:hover{ background-color: black; }


210

被折叠的 条评论
为什么被折叠?



