My button's color seems transparent but why?
-
I'm using QTDesigner 5.15.8 and trying to color buttons.
Here is a screenshot of my problem.
I have inserted one button and frame on my mainwindow.
Here is the stylesheet code of mainwindowQPushButton{ background-color: red; } QFrame{ background-color: red; }
They are same but as you see they look different. I couldnt find why it happened but it happens even if I created a new project...
-
Because it is how your OS draws a button.
Don't use a stylesheet on aQPushButton
if you want your "button" to be just a plain red rectangle or square.
Make your own subclass ofQPushButton
and use a painter to draw the rectangle yourself. -
It's the gradient from the fusion style what you're seeing here I would guess.
-
I found the solution. The reason is border....
Thanks for all...~~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; }
See Customizing QPushButton for an example. ~~