Changing app's QPushButtons' backgrounds with global stylesheet breaks its dimensions.
-
Hello all!
Imagine that I want all buttons in my prog to have a nice gradient look. And I use a global app stylesheet for this purpose. But something not understandable is going on when I'm trying to control the buttons' background through it.
If I have buttons in horizontal layout with spacer, and set the next app stylesheet
QPushButton { background: lightblue; border: 1px solid blue; /* need for full overpainting */ }
then widths of all of the buttons flow away, and buttons with a little text become very small.
If I add a line to the stylesheet:
min-width: 80px;
or, just
width: 80px;
then buttons with small text become ok, but buttons with long text not expand and their texts are partially hidden.
So, how to change background for all buttons and not to break its dimensions?
-
@Tink I tried paddings, it didn't help me.
-
@Tink said in Changing app's QPushButtons' backgrounds with global stylesheet breaks its dimensions.:
Or perhaps a large maximum width.
then all the buttons will be unnecessary large
-
@Tink said in Changing app's QPushButtons' backgrounds with global stylesheet breaks its dimensions.:
Or perhaps a large maximum width.
then all the buttons will be unnecessary large
@AlexNevskiy hmm... perhaps you need to change the sizePolicy?
-
So, I have found some sort of solution. Just need to set width of expanding spacer to minimum (0 for example). And it works some how.
-
@AlexNevskiy hmm... perhaps you need to change the sizePolicy?
@Tink said in Changing app's QPushButtons' backgrounds with global stylesheet breaks its dimensions.:
@AlexNevskiy hmm... perhaps you need to change the sizePolicy?
Which policy will make it work?
-
So, I have found some sort of solution. Just need to set width of expanding spacer to minimum (0 for example). And it works some how.
@AlexNevskiy said in Changing app's QPushButtons' backgrounds with global stylesheet breaks its dimensions.:
So, I have found some sort of solution. Just need to set width of expanding spacer to minimum (0 for example). And it works some how.
Makes sense.
-
@Tink said in Changing app's QPushButtons' backgrounds with global stylesheet breaks its dimensions.:
@AlexNevskiy hmm... perhaps you need to change the sizePolicy?
Which policy will make it work?
@AlexNevskiy said in Changing app's QPushButtons' backgrounds with global stylesheet breaks its dimensions.:
@Tink said in Changing app's QPushButtons' backgrounds with global stylesheet breaks its dimensions.:
@AlexNevskiy hmm... perhaps you need to change the sizePolicy?
Which policy will make it work?
Well i have most of my widgets on preferred since i dont understand the effects well enough:)
But if you add a pushbutton in designer it has horizontal: minimum.