Using StyleSheets is bad WAS Re: Konqueror lineedit Bug

Albert Astals Cid aacid at kde.org
Mon Nov 19 23:52:59 GMT 2007


A Dimarts 20 Novembre 2007, Aaron J. Seigo va escriure:
> 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.

So here is a real solution based on Fredrik suggestion.

Comments?

Albert

P.S: KdeUiProxySyle is the same as KonqProxyStyle, a candidate for KDE 4.1 
inclusion? His code is GPLv2+ in KonqProxyStyle but as it is really trivial i 
don't think he might have a problem relicensing.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: makeKLineEditWork.patch
Type: text/x-diff
Size: 13073 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20071120/ed90922a/attachment.patch>


More information about the kde-core-devel mailing list