Important: Please read the Qt Code of Conduct -

[Solved] Can't set background-color of a QPushButton.

  • I am having many issues with QSS, but lets take this 1 step at a time. I try to style a QPushButton. Text color is fine, I can change that, but not background-color... I've tried accessing the button in many ways using CSS class, or button itself (#). They can all change the text color fine, but not background color.

  • Allright, step #1, read updated documentation!


    bq. Warning: If you only set a background-color on a QPushButton, the background may not appear unless you set the border property to some value. This is because, by default, the QPushButton draws a native border which completely overlaps the background-color. For example,
    @QPushButton { background-color: red; border: none; }@

Log in to reply