系统性并完整的为pyqt5的常用控件分别创建仿MacOS系统风格的完整可用的qss主题文件
时间: 2024-01-21 09:17:32 浏览: 154
pyqt 常用控件qss设置
好的,以下是常用控件的仿MacOS系统风格的qss主题文件:
1. QPushButton
```
QPushButton {
background-color: #F4F4F4;
border: none;
color: #5A5A5A;
padding: 8px 16px;
font-size: 14px;
}
QPushButton:hover {
background-color: #E6E6E6;
color: #5A5A5A;
}
QPushButton:pressed {
background-color: #D9D9D9;
color: #5A5A5A;
}
```
2. QComboBox
```
QComboBox {
border: none;
background-color: #F4F4F4;
padding: 8px 16px;
font-size: 14px;
}
QComboBox:hover {
background-color: #E6E6E6;
}
QComboBox:pressed {
background-color: #D9D9D9;
}
QComboBox::drop-down {
subcontrol-origin: padding;
subcontrol-position: top right;
width: 20px;
border-left-width: 1px;
border-left-color: #BFBFBF;
border-left-style: solid;
}
QComboBox::down-arrow {
image: url(./arrow_down.png);
}
```
3. QLineEdit
```
QLineEdit {
border-radius: 4px;
border: none;
background-color: #F4F4F4;
padding: 8px 16px;
font-size: 14px;
}
QLineEdit:hover {
background-color: #E6E6E6;
}
QLineEdit:focus {
border: 1px solid #BFBFBF;
}
```
4. QCheckBox
```
QCheckBox {
padding-left: 20px;
font-size: 14px;
}
QCheckBox::indicator {
width: 16px;
height: 16px;
}
QCheckBox::indicator:unchecked {
image: url(./checkbox_unchecked.png);
}
QCheckBox::indicator:checked {
image: url(./checkbox_checked.png);
}
```
5. QRadioButton
```
QRadioButton {
padding-left: 20px;
font-size: 14px;
}
QRadioButton::indicator {
width: 16px;
height: 16px;
}
QRadioButton::indicator:unchecked {
image: url(./radio_unchecked.png);
}
QRadioButton::indicator:checked {
image: url(./radio_checked.png);
}
```
6. QSlider
```
QSlider {
border: none;
background-color: transparent;
padding: 0;
}
QSlider::handle {
width: 16px;
height: 16px;
margin: -8px 0;
border-radius: 8px;
background-color: #F4F4F4;
}
QSlider::handle:hover {
background-color: #E6E6E6;
}
QSlider::sub-page {
background-color: #007AFF;
}
QSlider::add-page {
background-color: #D9D9D9;
}
```
7. QProgressBar
```
QProgressBar {
border: none;
background-color: #D9D9D9;
height: 8px;
}
QProgressBar::chunk {
background-color: #007AFF;
width: 8px;
}
```
8. QTabWidget
```
QTabWidget::pane {
border: none;
background-color: #F4F4F4;
}
QTabBar::tab {
border: none;
background-color: #F4F4F4;
color: #5A5A5A;
padding: 8px 16px;
font-size: 14px;
}
QTabBar::tab:hover {
background-color: #E6E6E6;
}
QTabBar::tab:selected {
background-color: #D9D9D9;
}
```
以上是常用控件的仿MacOS系统风格的qss主题文件,你可以根据需要进行调整。注意,如果使用图片作为控件的背景或图标,需要将图片放在项目目录下,并在qss文件中使用相对路径引用。
阅读全文