请帮我写一个 pyqt使主界面的颜色为炫酷次世代风格的qss代码
时间: 2024-05-05 12:16:32 浏览: 136
pyqt5 + QSS + qt designer写了一个登录和注册界面
以下是一个炫酷次世代风格的QSS代码示例,可以将其应用于PyQt主界面:
```
QWidget {
background-color: qlineargradient(x1:0, y1:0, x2:1, y2:1,
stop:0 #1e2b3f, stop:1 #2c3e50);
color: #bdc3c7;
font-size: 14px;
font-family: Arial;
}
QMenuBar {
background-color: #34495e;
color: #bdc3c7;
}
QMenuBar::item {
background-color: transparent;
}
QMenuBar::item:selected {
background-color: #2c3e50;
}
QMenu {
background-color: #34495e;
color: #bdc3c7;
border: 1px solid #2c3e50;
}
QMenu::item {
padding: 5px 20px;
}
QMenu::item:selected {
background-color: #2c3e50;
}
QPushButton {
background-color: #3498db;
color: #ffffff;
border: none;
border-radius: 3px;
padding: 5px 20px;
}
QPushButton:hover {
background-color: #2980b9;
}
QLineEdit {
background-color: #2c3e50;
color: #bdc3c7;
border: 1px solid #34495e;
border-radius: 3px;
padding: 5px;
}
QSpinBox, QDoubleSpinBox {
background-color: #2c3e50;
color: #bdc3c7;
border: 1px solid #34495e;
border-radius: 3px;
padding: 5px;
}
QComboBox {
background-color: #2c3e50;
color: #bdc3c7;
border: 1px solid #34495e;
border-radius: 3px;
padding: 5px;
}
QComboBox::drop-down {
background-color: transparent;
}
QComboBox::down-arrow {
image: url(icons/down_arrow.png);
width: 10px;
height: 10px;
}
QScrollBar:vertical {
background-color: #2c3e50;
border: none;
width: 14px;
margin: 0px 0px 0px 0px;
}
QScrollBar::handle:vertical {
background-color: #3498db;
min-height: 20px;
border-radius: 7px;
}
QScrollBar::add-line:vertical {
background-color: #2c3e50;
height: 14px;
subcontrol-position: bottom;
subcontrol-origin: margin;
}
QScrollBar::sub-line:vertical {
background-color: #2c3e50;
height: 14px;
subcontrol-position: top;
subcontrol-origin: margin;
}
QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
background-color: transparent;
}
QScrollBar:horizontal {
background-color: #2c3e50;
border: none;
height: 14px;
margin: 0px 0px 0px 0px;
}
QScrollBar::handle:horizontal {
background-color: #3498db;
min-width: 20px;
border-radius: 7px;
}
QScrollBar::add-line:horizontal {
background-color: #2c3e50;
width: 14px;
subcontrol-position: right;
subcontrol-origin: margin;
}
QScrollBar::sub-line:horizontal {
background-color: #2c3e50;
width: 14px;
subcontrol-position: left;
subcontrol-origin: margin;
}
QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {
background-color: transparent;
}
```
你可以将此代码复制到你的PyQt项目中,并使用setStyleSheet()方法将其应用于主窗口。例如,如果你的主窗口对象是"mainWindow",则可以这样应用:
```
mainWindow.setStyleSheet("上述代码")
```
请注意,这只是一个基本的QSS示例,你可能需要进一步调整它以适应你的应用程序需求。
阅读全文