Search code examples
pythonbuttonqwidgetqt-designer

Python QtDesigner >> Unable to change button color while button is "FLAT"


I'm a beginner in Python and QtDesigner and I've encountered a problem. I'm trying to change the color of a button that is in a widget and that is FLAT. The color I chose only shows while the button is pressed and not while nothing interacts with it.. I also want the button to be flat...

Keep in mind that I'm doing this exclusively in the QtDesigner window... in Edit Style Sheet >> Add Color >> background-color: rgb(255, 170, 0);

If the button is not FLAT, all is ok, but while it is FLAT, the color is the one I chose for the widget the button is in...

Any ideea what I should write in the stylesheet for the color to change while the button is NOT pressed ?

Thank you in advance for any help!


Solution

  • Try checking autoFillBackground.

    Alternatively, you can try to manually set the stylesheet (in Designer):

    border:none;
    background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #ffffff, stop: 1 #ffffff);
    

    Change the #ffffff to whatever color you want.