[Development] QWidget font settings propagation parent to child

Henry Skoglund henry at tungware.se
Thu Oct 24 10:50:07 CEST 2019

On 2019-10-24 08:13, Giuseppe D'Angelo via Development wrote:
> Il 23/10/19 16:28, Henry Skoglund ha scritto:
>> Question: is this hit or miss font propagation on Windows and Mac a 
>> bug or a feature? If it's a feature, could it be documented?
> Please do some extra investigation: who's setting those fonts?
> * Is it the style, e.g. in QStyle::polish(QWidget*)?
> * Is it coming from QApplication::font? Or maybe QStyle::polish(QApp*)?
> * Do the widgets have WA_SetFont enabled?
> etc.
> It certainly sounds surprising at first that some widgets don't 
> inherit the font, but there could be a good explanation. Lacking such 
> explanation, then we're talking about a quite serious bug.
First the easy questions:

* Do the widgets have WA_SETFont enabled? No, none of the kids, just the 
parent (because I called setFont() on it).
(The WA_SetFont() flag is pretty easy to understand (even for me :-) 
i.e. widgets with that flag=true says: leave me alone, don't do the font 
propagation on me, got my own font setting figured out.)

* Is it coming from QApplication::font()? No, because I do that 
setFont("Courier") on my top window. But if I comment that line out, my 
top widget would get that application default font instead (on my 
Windows PC it's "MS Shell Dlg 2", 8.25 point size).

Off topic: those 8.25 point sizes as default was an excellent choice 20 
years ago when the common display size was 1024x768 or so. Nowadays the 
display sizes are bigger, why not change those prewired 
QApplication::font point sizes to say 12 or even 14?

This is a pretty complicated subject, for example, for a QTableWidget, 
the font propagation works for the vertical and horizontal header rows, 
but not for the text inside the cells. And it's platform dependent, i.e. 
on Linux everything just *works*.

Anyway, the reason I started this thread was that I couldn't understand 
how the font propagation really worked. I would be perfectly happy with 
the current state of affairs, if it could be documented somehow. Right 
now QWidget's font documentation says that the font propagation should 
occur, except when the QWidget's isWindow() is true, but all of the 
widgets in my example: isWindow() == false.

I'll look into the QStyle stuff, and I'm pretty sure as you say, that 
the behavior I'm observing is a result of many years hard work with the 

Rgrds Henry

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20191024/46f9879c/attachment.html>

More information about the Development mailing list