Skip to content

Enable fractional DPI scaling on Windows

Alvin Wong requested to merge alvin/fractional-dpi-scaling into master

This adds a series of patches related to https://bugreports.qt.io/browse/QTBUG-53022 for Windows to allow enabling experimental support for fractional DPI scaling.

In addition, a patch to fix https://bugreports.qt.io/browse/QTBUG-72504 (which is set to be in Qt 5.12.3) is included..

The exact list of patches is as follow:

These series of patches adds the option QGuiApplication::setHighDpiScaleFactorRoundingPolicy to control how the DPI scale factor is rounded (or not), which can also be overridden by the environment variable QT_SCALE_FACTOR_ROUNDING_POLICY. The options include:

  • Round: Round up for .5 and above.
  • Ceil: Always round up.
  • Floor: Always round down.
  • RoundPreferFloor: Round up for .75 and above.
  • PassThrough: Don't round.

Currently the default option (for when fractional scaling is disabled by the user) is explicitly set to RoundPreferFloor (where 1.5x is rounded down to 1x), since users with 1.5x scaling will tend to complain that the UI gets too large and rounding down can be a more acceptable behaviour. The past behaviour was akin to Round but it is more of an annoyance to users.

There is a new config option "Enable fractional scale factor" under General->Window for user to enable the PassThrough behaviour. This option is enabled by default. Note that if the user have the environment variable QT_SCALE_FACTOR_ROUNDING_POLICY set it will still override any behaviour set by Krita.


To test: With the Windows display settings set to 150% scaling:

  1. By default, the scale factor is set to 1.5x and the UI elements looks to be sized appropriately.
  2. By disabling the "Enable fractional scale factor" option, the scale factor is rounded down to 1x (causing UI elements to be smaller than expected).
  3. By disabling the "Enable fractional scale factor" option and with QT_SCALE_FACTOR_ROUNDING_POLICY=Round, the scale factor is rounded down to 1x (causing UI elements to be smaller than expected).

If the "Enable Hi-DPI support" option is disabled, the above options will have no effect and none of the UI elements will be scaled by high DPI scaling.

Edited by Mathias Wein

Merge request reports

Loading