[PyQt] Re: QStyle manipulations

Hans-Peter Jansen hpj at urpla.net
Tue Jul 28 11:52:53 BST 2009


Am Dienstag, 28. Juli 2009 schrieb Giovanni Bajo:
> On Tue, 28 Jul 2009 01:24:19 +0200, "Hans-Peter Jansen" <hpj at urpla.net>
> >
> > The basic problem I try to solve, is that I've created a typical
> > QWidget based sub class of a combined QCheckBox and QToolButton. And
> > while on my Linux desktop with QPlastiqueStyle the spacing is well
> > (similar to other widgets, on the Mac with QMacStyle the vertical
> > spacing of those custom widgets is nearly twice as high as ordinary
> > check boxes. I've tried to control the margins from within my widget,
> > but the margins are controlled
> >
> > via private QWidget methods and attributes - unreachable from PyQt.
>
> Isn't it possible to adjust the margins through CSS?

Unfortunately, I can't, since in Qt's "Box Model" you can _add_ margins, 
borders, padding around a given content, but in QMacStyle and according to 
Apple style guides, widgets _spacing_ is depending on preceding and 
succeeding widget types. And since QMacStyle can't rate my custom QWidgets, 
it uses an arbitrary maximum value. 

Update: I was able to fix the issue (and I feel stupid :-|).

I've subclassed QCheckBox directly now, and fiddled a bit with the 
additional button geometry in some event handlers, eh voila, the Mac 
handles the custom widget like an ordinary check box. Duuh, sometimes, you 
don't see the forest because all the trees...

Thanks,
Pete

BTW, Giovanni, I haven't forgotten your last pyinstaller inquiry, but didn't 
found time to collect and describe my findings. Will do soon...


More information about the PyQt mailing list