Question about setting Push button background color
-
Hi, Im setting my push button background color by:
ui->colorPushButton->setStyleSheet("QPushButton { background-color : blue }");
The color changes only when I press the button, and changes back when my click releases. How to change the background color even I don't touch the button? Thanks.
-
Hi
The part of the code that draws the frame/border doesn't use the background color for the background.
the trick is to remove the border and then it showsQPushButton { border: none; background-color : blue; }
-
@dalishi said in Question about setting Push button background color:
setStyleSheet("QPushButton { background-color : blue }");
Not sure about your question. The setting seems OK. What is the color on your machine when the button is not pressed?
On my machine, the color is same as yours. It becomes a bit darker when the button is pressed. -
Hi
The part of the code that draws the frame/border doesn't use the background color for the background.
the trick is to remove the border and then it showsQPushButton { border: none; background-color : blue; }
-
@dalishi said in Question about setting Push button background color:
setStyleSheet("QPushButton { background-color : blue }");
Not sure about your question. The setting seems OK. What is the color on your machine when the button is not pressed?
On my machine, the color is same as yours. It becomes a bit darker when the button is pressed.