系统性的为pyqt5的各个控件分别创建仿MacOS系统风格的完整可用的qss主题文件
时间: 2024-01-21 14:17:26 浏览: 158
一款非常漂亮的仿苹果风格的控件
以下是一些常用的 PyQt5 控件,以及它们对应的仿 MacOS 系统风格的 QSS 主题文件:
## QPushButton
```css
QPushButton {
background-color: transparent;
border-radius: 10px;
border: 2px solid #C3C3C3;
color: #000000;
font-size: 14px;
min-width: 80px;
padding: 5px;
}
QPushButton:hover {
background-color: #F6F6F6;
border: 2px solid #C3C3C3;
}
QPushButton:pressed {
background-color: #E3E3E3;
border: 2px solid #C3C3C3;
}
```
## QComboBox
```css
QComboBox {
background-color: #FFFFFF;
border-radius: 10px;
border: 2px solid #C3C3C3;
color: #000000;
font-size: 14px;
min-width: 80px;
padding: 5px;
}
QComboBox:hover {
background-color: #F6F6F6;
border: 2px solid #C3C3C3;
}
QComboBox:pressed {
background-color: #E3E3E3;
border: 2px solid #C3C3C3;
}
QComboBox::drop-down {
subcontrol-origin: padding;
subcontrol-position: top right;
width: 20px;
border: none;
}
QComboBox::down-arrow {
image: url(your/path/to/down_arrow.png);
width: 20px;
height: 20px;
}
```
## QLineEdit
```css
QLineEdit {
background-color: #FFFFFF;
border-radius: 10px;
border: 2px solid #C3C3C3;
color: #000000;
font-size: 14px;
min-width: 80px;
padding: 5px;
}
QLineEdit:hover {
background-color: #F6F6F6;
border: 2px solid #C3C3C3;
}
QLineEdit:focus {
background-color: #E3E3E3;
border: 2px solid #C3C3C3;
}
```
## QCheckBox
```css
QCheckBox {
background-color: transparent;
color: #000000;
font-size: 14px;
}
QCheckBox::indicator {
width: 20px;
height: 20px;
}
QCheckBox::indicator:unchecked {
image: url(your/path/to/unchecked.png);
}
QCheckBox::indicator:checked {
image: url(your/path/to/checked.png);
}
```
## QRadioButton
```css
QRadioButton {
background-color: transparent;
color: #000000;
font-size: 14px;
}
QRadioButton::indicator {
width: 20px;
height: 20px;
}
QRadioButton::indicator:unchecked {
image: url(your/path/to/unchecked.png);
}
QRadioButton::indicator:checked {
image: url(your/path/to/checked.png);
}
```
## QSlider
```css
QSlider::groove:horizontal {
height: 4px;
background-color: #C3C3C3;
border-radius: 2px;
}
QSlider::handle:horizontal {
width: 16px;
height: 16px;
margin: -6px 0;
border-radius: 8px;
background-color: #FFFFFF;
border: 2px solid #C3C3C3;
}
QSlider::handle:horizontal:hover {
background-color: #E3E3E3;
}
QSlider::handle:horizontal:pressed {
background-color: #C3C3C3;
}
```
## QProgressBar
```css
QProgressBar {
border: 1px solid #C3C3C3;
border-radius: 5px;
text-align: center;
}
QProgressBar::chunk {
background-color: #C3C3C3;
border-radius: 5px;
}
```
## QLabel
```css
QLabel {
background-color: transparent;
color: #000000;
font-size: 14px;
}
```
以上是一些常用的 PyQt5 控件的仿 MacOS 系统风格的 QSS 主题文件,你可以根据自己的需要进行修改和定制化。
阅读全文