from PyQt5.Qt import *
import sys
class Window(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle("")
self.resize(800, 800)
self.setup_ui()
def setup_ui(self):
btn = QPushButton(self)
print(btn.isFlat())
# 测试一
btn.setText('btn')
btn.setStyleSheet('background-color:red')
# 测试二
btn.setFlat(True)
btn.setStyleSheet('background-color:red')
# 创建一个应用程序对象
app = QApplication(sys.argv)
window = Window()
window.show()
# 应用程序的执行(进入到消息循环,无限循环中,检测整个程序所接收到的用户的交互信息)
sys.exit(app.exec_())
按钮被设置扁平化后
该按钮没有了边框
也没法设置背景颜色
enjoy