Using StyleSheets is bad WAS Re: Konqueror lineedit Bug

Aaron J. Seigo aseigo at
Mon Nov 19 23:16:50 GMT 2007

On Monday 19 November 2007, Rafael Fernández López wrote:
> Hi,
> > My idea would be removing the stylesheet, because passing the font to the
> > stylesheet string "fixes" the current bug but will break when someone
> > calls setFont over a KLineEdit. But i did not find a way to set
> > "padding-right" property on a QLineEdit without using StyleSheets.
> Well, it is only needed to reimplement paintEvent() and override some stuff
> on event() method to check if clicks were made on that part of the widget.

it's not about checking for clicks, it's about laying out the text. most of 
that is hidden in private API code in Qt. i had a version that did this waaay 
back by abusing private API (essentially copying a private class header into 
my code ;), but stylesheets obviated this.

i still don't see how it would be possible without access to private API 
unless you reimplemented *all* of qlineedit's painting yourself.

> > And may i suggest adding a krazy check about setStyleSheet calls? If Qt
> > has that restriction about fonts and styleSheets i think using
> > styleSheets should be recommended against.
> ++

no. what you WANT to do is implement QWidget::changeEvent(QEvent*) and when 
you get a QEvent::FontChange update the stylesheet if needed.

i would do this right now exept i'm eyeballs deep in plasma layout code and 
have no energy left for other stuff today. if nobody gets to it by end of 
week, i will.

but please, look for real solutions (e.g. changeEvent) before ripping out what 
is a very elegant and rather neat little feature.

Aaron J. Seigo
humru othro a kohnu se
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43

KDE core developer sponsored by Trolltech
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <>

More information about the kde-core-devel mailing list