Hi all, Lately I’ve spent some time on high-DPI configuration options for Qt. This is a somewhat complex area, with many different setups in the field. I’d like to expose the patches to a wider audience to make sure we implement something that works as well as possible. Please feel free to provide any feedback, either privately or on this list.
The patches are based on Qt 5.6 and are available at: https://codereview.qt-project.org/157175 (Use the “checkout” option to get the entire patch series) Documentation patch is at: https://codereview.qt-project.org/172125 The scope of the changes is improving the Qt::HighDpiScaling mode, with a focus on configuration. I’ve tested on Windows and X11, with macOS as a dev platform. The result of the work is some behavior changes and several new config options. Should I test/How to I use this? 1) Set QT_AUTO_SCREEN_SCALE_FACTOR=1 or Qt::HighDpiScaling. 2) If not happy then - Try setting QT_FONT_DPI and/or QT_SCALE_FACTOR to see how the application reacts. Is it an application or QtWidgets/QtQuick issue? - Set QT_USE_PHYSICAL_DPI=1 (if you know the values are correct) - Set QT_SCREEN_SCALE_FACTORS=a;b;c to hardcode scale factors. (Known issue: QT_AUTO_SCREEN_SCALE_FACTOR needs to be set as well for this) 3) Report findings to patch author; include "tests/manual/highdpi --metrics” outpu and screenshots (if possible). Some platform specific notes: - X11: If you’ve had problems with mismatched text/ui sizes this should now be better (if not solved). Qt now uses the global logical DPI by default. - Windows: Use fractional scale factors (like 150%) directly: QT_SCALE_FACTOR_ROUNDING_POLICY=PassThrough (See below for disclaimer and caveats) Changes in detail: - qtbase/tests/manual/highdpi --metrics prints the current configuration. Example: screen name: Virtual1 widget devicePixelRatio: 1 widget logicalDpi: 96 platform screen logicalDpi: 96 platform screen logicalBaseDpi: 96 platform screen devicePixelRatio: 1 platform screen physicalDpi: 96.1115 QT_FONT_DPI: QT_SCALE_FACTOR: QT_AUTO_SCREEN_SCALE_FACTOR: QT_SCREEN_SCALE_FACTORS: QT_USE_PHYSICAL_DPI: QT_SCALE_FACTOR_ROUNDING_POLICY: QT_DPI_ADJUSTMENT_POLICY: Here, the “widget” section are the values the application sees, the “platform” section are the values returned by the OS/WS via the Qt platform plugin, and finally QT_ sections shows the currently set environment variables. - The screen logical DPI is now used for configuring the devicePixelRatio value. This has been the case for Windows for some time; now all relevant platforms get the same behavior. Set QT_USE_PHYSICAL_DPI to use physical DPI. - In relation ot the above Qt now uses _either_ the logical or physical DPI, which should reduce chance of getting inconsistent text and UI sizes. - Qt may now optionally use non-integer factors (like 150% on windows): QT_SCALE_FACTOR_ROUNDING_POLICY=PassThrough We know that this may cause painting artifacts, in particularly with native styles. On the other hand there are rapports that custom-styled apps work fine. - 1.5x (150% on Windows) is now rounded down to 1x: The visual effect of this is that content appears visually small on such systems instead of visually large. This arguably more acceptable. The rounding policy controls this as well: QT_SCALE_FACTOR_ROUNDING_POLICY=Round|Ceil|Floor|RoundPreferFloor (default) - QT_FONT_DPI now works on all platforms (mostly for testing purposes) - QT_SCREEN_SCALE_FACTORS now correctly overrides the screen factors. - QScreen::physicalDotsPerInch() is now a more physical value, independent of Qt or OS scale factors, but not independent of scaling not detectable by Qt such as the macOS “More Space” setting. Thanks for reading this far :) - Morten _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest