pyqt5中treewidget有哪些QSS样式
时间: 2024-02-29 16:51:39 浏览: 156
pyqt5 qss常用美化资源包
QTreeWidget是PyQt5中的树形控件,支持使用QSS进行样式设置。以下是一些常用的QSS样式:
1. 设置树形控件的背景色和前景色:
```qss
QTreeWidget {
background-color: #ffffff;
color: #000000;
}
```
2. 设置树形控件中每个项目的高度和字体:
```qss
QTreeWidget::item {
height: 30px;
font-size: 14px;
}
```
3. 设置树形控件中选中项目的背景色和前景色:
```qss
QTreeWidget::item:selected {
background-color: #0078d7;
color: #ffffff;
}
```
4. 设置树形控件中鼠标悬停的项目的背景色和前景色:
```qss
QTreeWidget::item:hover {
background-color: #f0f0f0;
color: #000000;
}
```
5. 设置树形控件中展开/折叠图标的样式:
```qss
QTreeView::branch:open:has-children {
image: url(icons/branch_open.png);
}
QTreeView::branch:closed:has-children {
image: url(icons/branch_closed.png);
}
QTreeView::branch:has-children:!has-siblings:closed,
QTreeView::branch:closed:has-children:has-siblings {
border-image: none;
image: url(icons/branch_closed_collapsed.png);
}
QTreeView::branch:open:has-children:!has-siblings,
QTreeView::branch:open:has-children:has-siblings {
border-image: none;
image: url(icons/branch_open_collapsed.png);
}
```
以上是一些常用的QSS样式,可以根据需要进行修改和扩展。
阅读全文