silvercircle/github/io
A Jekyll test site with no particular purpose.

Set font scaling for Qt applications

Last modified:
245 Words
Written by AlexVie in DevelopmentQtC++ | Sun, 03. September 2017, 10:25
Reading time: approx. 0 minute(s).

Qt is a great thing, for most parts, but sometimes it does not follow UI guidelines strictly enough. On Windows, Qt applications have a tendency of using non-standard fonts at non-standard sizes. For example, QtCreator uses the Tahoma font at a fairly small size - too small for standard DPI settings that are still widely in use on some older systems, mainly laptops.

But Qt also allows hassle free UI scaling at any desirable value that works fairly well and can be set globally or per application by defining an environment variable:

set QT_SCALE_FACTOR=2
qtcreator.exe

do this in a shell, and QtCreator will launch with everything scaled to twice its size. Fonts will appear bigger, but also all UI elements. Since this scaling is implemented in Qt at a very low level, it works consistently throughout the entire application.

So, you have the choice. You can set the QT_SCALE_FACTOR environment variable globally via the control panel, or use a .cmd file to set it before you launch a specific application. The value must be a floating point number and can be smaller than 1, so yes, it is possible to downscale the UI.

The following screen shot illustrates the difference between no scale and QT_SCALE_FACTOR = 2. It was taken at a resolution of 1920x1080 at the standard DPI setting under Windows.

Screen shot showing the different scaling (click to enlarge)
Screen shot showing the different scaling (click to enlarge)
Screen shot showing the different scaling (click to enlarge)