Using StyleSheets is bad WAS Re: Konqueror lineedit Bug

David Faure faure at
Mon Nov 19 23:29:40 GMT 2007

On Tuesday 20 November 2007, Aaron J. Seigo wrote:
> no. what you WANT to do is implement QWidget::changeEvent(QEvent*) and when 
> you get a QEvent::FontChange update the stylesheet if needed.
You mean adding the font name into the CSS code? This seems to be the only way indeed.
However, watch out for the infinite loop:
setFont calls FontChange calls setStyleSheet calls QStyleSheetStyle::repolish(w) calls updateWidgets calls style->polish(w) calls QStyleSheetStyle::setPalette() calls w->setFont, GOTO 10.
Somehow you'll have to distinguish "setFont done by the user" from "setFont done by the style". No idea other than a nasty boolean-based re-entrancy protection...

David Faure, faure at, sponsored by Trolltech to work on KDE,
Konqueror (, and KOffice (

More information about the kde-core-devel mailing list