[Interest] scale all fonts
Bo Thorsen
bthorsen at ics.com
Tue Mar 19 12:08:07 CET 2013
Den 19-03-2013 11:27, Hamish Moffatt skrev:
> Is it possible to apply a scaling to all font sizes used in an application?
>
> I can see Qt is doing the right thing by converting point sizes to pixel
> sizes in accordance with the DPI of the display. Now suppose I want to
> override the DPI, or redefine point to be other than 1/72" (achieves the
> same). Is this possible?
Well, yes and no. You can't say a widget uses "standard pixel size plus X".
You can set a standard font on QApplication with the size you want:
QFont font;
font.setPixelSize(23);
QApplication::setFont(font);
That part is easy enough.
But in places where you have custom drawing with other sizes, you need
to do the same kind of thing:
QFont f; // This is the standard font
f.setPixelSize(f.pixelSize() + 3);
setFont(f); // Or use f with the painter
You can listen for font changes with the changeEvent() in widgets. If
you use the QWidget::setFont(), this is necessary. If you just use it in
the painter, it's not necessary.
In all text based widgets with rich text, you can use <font size="+3">
and then it just works.
With style sheets, you can't do this.
In QML you can do sort of the same things. But I assumed this was a
QWidget based question.
Bo.
--
Bo Thorsen, European Qt Manager, Integrated Computer Solutions
ICS - Delivering World-Class Applications for Embedded & Mobile Devices
http://ics.com/services
More information about the Interest
mailing list