I found a way to get the buttons to have a solid color background.
Qt Code:
pushButton->setStyleSheet("background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 white, stop: 1 white);");To copy to clipboard, switch view to plain text mode
Now the question becomes why do I have to use a qlineargradient to get the QPushButton to be a solid color.![]()
Does the problem occur with all widget styles or a particular one (probably plastique)?
Lexrst (22nd April 2008)
The style of the widget seems to be the cause of my problem. All other styles I tried (CDE, Motif, Cleanlooks, Windows) seem to work as expected, giving me the solid color background I expected. Only Plastique seems to have the issue described in this thread.
So I have a way to accomplish what I need but now the question becomes..
Why does the plastique style override what I put in the StyleSheet and force it to be a gradient when I specify a single color?
Thanks for a push in the right direction!
What happens if you overload the style for different states of the button like :hover?
QPushButton, QPushButton:hover { background: white; color: black; }
Sorry for not getting back to this sooner. Been focused on other projects.
If I overload for :hover, with the above sytnax, using the Plastique style I still don't get a solid color background in the button, it's a white to grey gradient. I get similar results if I overload for :pressed with the same syntax.
So I'm using a qlineargradient to get a solid color background for my QPushButton, when using the Plastique style.
From my testing this only appears to happen with the Plastique style and not with any other sytle that I tried.
This might be a bug in stylesheets or plastique.
Bookmarks