-- coding: utf-8 --
'''
【简介】
QSS样式
'''
from PyQt5.QtWidgets import *
import sys
class WindowDemo(QWidget):
def init(self):
super().init()
btn1 = QPushButton(self)
btn1.setText('按钮1')
btn2 = QPushButton(self)
btn2.setText('按钮2')
vbox = QVBoxLayout()
vbox.addWidget(btn1)
vbox.addWidget(btn2)
self.setLayout(vbox)
self.setWindowTitle("QSS样式")
if name == "main":
app = QApplication(sys.argv)
win = WindowDemo()
qssStyle = '''
QPushButton {
background-color: red
}
'''
win.setStyleSheet(qssStyle)
win.show()
sys.exit(app.exec_())