我正在尝试使用 python Qt 更改边框的背景颜色,但只设置了边框。
这是代码:
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtCore import pyqtSlot
import math
import sys
class Frame(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.setGeometry(300, 100, 1000, 500)
pal = QPalette()
self.setAutoFillBackground(True)
self.setPalette(pal)
button = QPushButton('Clear Knots')
button.clicked.connect(quit)
pal.setColor(QPalette.Button, QColor(255,0,0,255))
button.setPalette(pal)
button.setAutoFillBackground(True)
#button.setStyleSheet("background-color: red;")
Layout = QGridLayout()
Layout.addWidget(button, 2,0)
self.setLayout(Layout)
self.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Frame()
sys.exit(app.exec_())
结果:
慕容708150
相关分类