Using StyleSheets is bad WAS Re: Konqueror lineedit Bug

Albert Astals Cid aacid at kde.org
Mon Nov 19 22:35:08 GMT 2007


A Dilluns 19 Novembre 2007, Albert Astals Cid va escriure:
> ... also known as "Bug with comboboxes with lineedits inside a toolbar"
>
> Hi,
>    Qt combo boxes don't take into account their lineedit font when
> calculating their size hint, so if you set your toolbar font size to be 8
> and your General font size to be 20, you will see that the Konqueror
> location line is small but the fonts in it are HUGE, that is, it does not
> work, because it uses 8 for calculating combobox height, because it's on
> the toolbar, but then contents are drawn using 20 because it's the lineedit
> doing the actual drawing.
>
> I'm not sure this is a Qt bug, as maybe it's a "requirement" that both the
> lineedit and the combobox have the same font, as it really does not make
> sense to me having different sizes there.
>
> So i am asking myself if for lineedits that are in a qcombobox inside a
> toolbar we should use the toolbar font size instead of the general font
> size, that is, it's our bug or a Qt one?

Ok, so i found the real bug, and it is our bug, we are using stylesheets in 
KLineEdit, which QWidget documentation says 

Warning: Do not use this function in conjunction with Qt Style Sheets. The 
font of a widget can be customized using the "font" style sheet property.

So we either remove the stylesheet or pass the current font to the stylesheet 
string we set. 

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.

Anyone knows a better way? Or someone i can ask about it?

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.

Albert

>
> Comments? Suggestions?
>
> Albert






More information about the kde-core-devel mailing list