PyQt5按钮背景色不采用

2024-10-01 19:23:18 发布

您现在位置:Python中文网/ 问答频道 /正文

这是按钮的代码:

    self.pushButton.setFont(font)
    self.pushButton.setStyleSheet("background-color: qlineargradient(spread:pad, x1:0.0568182, y1:0.126, x2:0.75, y2:0.227, stop:0.0738636 rgba(0, 255, 0, 255), stop:0.840909 rgba(0, 136, 0, 255));\n")
    self.pushButton.setFlat(True)
    self.pushButton.setObjectName("pushButton")

虽然我给这个按钮设置了一个背景渐变,但它不起作用。在

这是正常情况下的按钮:

enter image description here

当它被按下时:

enter image description here


Tags: 代码self按钮colorbackgroundstopx1font

热门问题