Qt5 - setting background color to QPushButton and QCheckBox

后端 未结 6 685
小蘑菇
小蘑菇 2020-12-06 05:01

I\'m trying to change the background color of a QAbstractButton (either a QPushButton or QCheckBox) in Qt5 and having zero luck.

This does nothing:

p         


        
6条回答
  •  死守一世寂寞
    2020-12-06 05:17

    Changing the Dialog styleSheet Property works for me, set this property to:

    QPushButton:pressed {
        background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1,   stop:0 rgba(60, 186, 162, 255), stop:1 rgba(98, 211, 162, 255))
    }
    QPushButton {
         background-color: #3cbaa2; border: 1px solid black;
         border-radius: 5px;
    }
    
    QPushButton:disabled {
        background-color: rgb(170, 170, 127)
    }
    

提交回复
热议问题