[Interest] Styling a QPushButton via stylesheet destroys sizing

Hamish Moffatt hamish at risingsoftware.com
Thu Sep 10 08:01:32 CEST 2015

On 08/09/15 01:04, Thiago Macieira wrote:
> On Monday 07 September 2015 17:38:07 Hamish Moffatt wrote:
>> I'm trying to style buttons via the stylesheet. Just colours, border,
>> font and so forth.
>> However as soon as I apply any property as simple as a border, the
>> button no longer sizes itself according to the rules of the platform.
>> For example something as simple as:
>> QPushButton { border: 1px solid red; }
>> Now the button will shrink to the width of the text, while a normal Qt
>> button on Windows has a minimum width of around 100px or so.
>> Further, setting a min-width doesn't fix this because then the button no
>> longer gets wider to fit longer text.
>> Any suggestions for solving this?
> Stop using stylesheets. At the very least, stop setting the property that
> causes the issue.

I can't set a border-image any other way though, and just that is enough 
to upset the sizing.

Otherwise how else would I style my application? Creating a new 
descendent of QStyle is far from trivial.


More information about the Interest mailing list