Qt样式表
- 1、前言
- 2、QWdiget窗口添加背景图片
-
- 3、主题1(黑色背景+发光边框+冷色调)
- 3.1 QWidget
- 3.2 QPushButton
- 3.3QLineEdit
- 3.4 QTextEdit
- 4、主题二(极简冰川蓝)
- 4.1QWidget
- 4.2 QLineEdit
- 4.3QTextEdit
- 4.4QPushButton
- 总结
1、前言
前言:记录和存储一些样式表,方便自己使用也方便别人借鉴。 |
2、QWdiget窗口添加背景图片
如果Qt窗口是QWidget
直接添加背景图片会显示不出来。



像上面一样,插入图片虽然在ui界面会显示,但是运行之后,并不会显示出来。 |
2.1使用Frame解决





3、主题1(黑色背景+发光边框+冷色调)

3.1 QWidget
QWidget {
background-color: #0a0a1a;
color: #00ffff;
font-family: "Consolas";
}
3.2 QPushButton
QPushButton {
background: transparent;
border: 2px solid #00ffff;
border-radius: 3px;
color: #00ffff;
padding: 10px 20px;
font-size: 14px;
text-transform: uppercase;
}
QPushButton:hover {
background: rgba(0, 255, 255, 0.1);
box-shadow: 0 0 15px #00ffff;
}
3.3QLineEdit
QLineEdit {
background: #1a1a2a;
border: 2px solid #4a4aff;
border-radius: 5px;
padding: 8px;
color: #ffffff;
}
QLineEdit:focus {
border-color: #00ffff;
box-shadow: 0 0 10px #00ffff;
}
3.4 QTextEdit
QTextEdit {
background-color: #1a1a2a;
border: 2px solid #4a4aff;
border-radius: 5px;
color: #00ffff;
font-family: "Consolas";
padding: 8px;
selection-background-color: #4a4aff;
selection-color: white;
}
QTextEdit:focus {
border-color: #00ffff;
box-shadow: 0 0 12px rgba(0, 255, 255, 0.3);
}
4、主题二(极简冰川蓝)

4.1QWidget
QWidget{
background: qlineargradient(
x1:0 y1:0, x2:1 y2:1,
stop:0 #E0F7FA, stop:1 #EBF5FB
);
border-radius:20px;
}
4.2 QLineEdit
QLineEdit {
background: rgba(255, 255, 255, 0.8);
border: 1px solid #B0E0E6;
border-radius: 8px;
padding: 8px;
color: #2C3E50;
}
QLineEdit:focus {
border-color: #87CEEB;
}
4.3QTextEdit
QTextEdit {
background: rgba(255, 255, 255, 0.8);
border: 1px solid #B0E0E6;
border-radius: 8px;
padding: 15px;
color: #2C3E50;
font: 16px "Arial";
}
QTextEdit:focus {
border-color: #87CEEB;
}
QTextEdit::placeholder {
color: #6C7A89;
}
4.4QPushButton
QPushButton {
background: qlineargradient(
x1:0 y1:0, x2:0 y2:1,
stop:0 #87CEEB, stop:1 #B0E0E6
);
border: none;
border-radius: 12px;
padding: 10px 24px;
color: #2C3E50;
font-weight: bold;
}
QPushButton:hover {
background: qlineargradient(
x1:0 y1:0, x2:0 y2:1,
stop:0 #6495ED, stop:1 #AFEEEE
);
}
QPushButton:pressed {
background: qlineargradient(
x1:0 y1:0, x2:0 y2:1,
stop:0 #4682B4, stop:1 #87CEFA
);
}
总结
以上就是Qt的一些样式表了,后续我也会不定期更新一些好看的样式表,浏览过程中,
如若发现错误,欢迎大家指正,有问题的可以评论区留言或者私信。最后,如果大家觉
得有所帮助,可以点一下赞,谢谢大家!世界扑朔迷离,愿我们保持冷静,继续前行! |