[Development] Revisiting high-DPI configuration options

Nikita Krupenko krnekit at gmail.com
Wed Jul 27 01:49:31 CEST 2016

2016-07-19 15:58 GMT+03:00 Shawn Rutledge <Shawn.Rutledge at qt.io>:
>> App should remember of couse this setting to restore it back at restart
> How should Qt encourage this?  So far we have QSettings, but you need to define your own setting.  And we have not made it easy to scale all fonts simultaneously, interactively.  Bindings are too cumbersome and expensive to be the universal solution.  To avoid setting the font on every individual Text item in a QtQuick app, for example, you can use QGuiApplication::setFont().  But that’s just for the default.  Maybe there should be an event of some sort when you do that at runtime, which every Text will react to, and which will then trigger the necessary layout changes.  But that would only take care of Text which uses the default font, so we need that unit support in QML (which has been discussed for years but not done yet) to be able to have a unit which represents the default font size, so that larger text could have a size 1.2x as big as the default instead of an actual point size.  Or maybe the event should be sent when you do QHighDpiScaling::setScreenFactor(), but that’s private API so far, and it’s still not clear to me which of those Qt high dpi-things are intended to affect only or mainly font sizes, and which of them demand everything to be scaled even if it will cause crappy results (scaling up pixmaps or pre-rendered widgets by non-integral ratios).  The prototype zoom-slider is in qtbase/tests/manual/highdpi, but you can see what goes wrong with that.  We need a similar test for QtQuick to see what goes wrong with dynamic scaling there.

In Material Design guidelines [1] all font sizes are in scaleable
pixels (sp). So this size could be multiplied by some factor and all
fonts should scale equally.

I think, it's worth to add the support of the font scale factor to the
Qt (enabled by something like Qt::AA_EnableFontScaling). And platform
plugin could try to get font scale factor from the OS settings and use
it by default.

[1] https://material.google.com/layout/units-measurements.html#units-measurements-scaleable-pixels-sp-

More information about the Development mailing list