[Interest] Styling a QPushButton via stylesheet destroys sizing

Thiago Macieira thiago.macieira at intel.com
Mon Sep 7 17:04:01 CEST 2015

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.

Depending on the property set via stylesheets, the button switches from native 
style to the QCommonStyle style, which accepts all CSS properties.

Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center

More information about the Interest mailing list