简体   繁体   English

PyQt5按钮背景色不起作用

[英]PyQt5 button background color not taking effect

Here is the button's code: 这是按钮的代码:

    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")

Although I set a background gradient to this button, it's not taking effect. 尽管我为该按钮设置了背景渐变,但是它没有生效。

Here's the button normally: 通常是以下按钮:

在此处输入图片说明

Here's when it's pressed down: 按下时:

在此处输入图片说明

Ok. 好。 It's solved. 解决了

The problem was, I was using background-color but background:#fff did the trick. 问题是,我使用的是background-color,但是background:#fff可以解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM