Is there a reason plasma still disables $QT_AUTO_SCREEN_SCALE_FACTOR?

The environment variable QT_AUTO_SCREEN_SCALE_FACTOR gets explicitly disabled during startup of plasma:

void setupPlasmaEnvironment()
{
    // Manually disable auto scaling because we are scaling above
    // otherwise apps that manually opt in for high DPI get auto scaled by the developer AND manually scaled by us
    qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "0");

This variable however prevents proper scaling of Qt 5 apps in an X11 plasma 6 session. If I start these apps with the environment variable set, they scale properly. Qt 6 apps are not affected by this variable, as it is deprecated by QT_ENABLE_HIGHDPI_SCALING

I use 175 % scaling. Setting the variable manually in .config/plasma-workspace/env/high-dpi.sh, the variable gets overwritten by startplasma.

Examples:

Qt 5 with scaling

Qt 5 with only font scaling

I put these variables in startkde/startplasma.cpp, so far with no bad side effects:

qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1");
qputenv("QT_ENABLE_HIGHDPI_SCALING", "1");

The last one is a bit superfluous, as Qt 6 apps have highDPI scaling enabled by default. I have no adverse effects in X11 or Wayland. Tested on screens with 100 %, 125 %, 170 % and 175 %. I’m even using different scale per monitor, something highly unsupported by KDE on X11!

I suspect it works now, because Qt 6 is way better in terms of scaling for different pixel densities than Qt 5. Qt 5 got a lot better during it’s lifetime, all the different hacks in KDE, that were still needed for e.g. Qt 5.6, are no longer needed in Qt 5.15.

This is annoying for me because I use QT_AUTO_SCREEN_SCALE_FACTOR to make the Kiwix AppImage GUI readable. The problem is KDE-Plasma session save/autostart. When I login and Kiwix gets auto started it is tiny. No matter where I try to set QT_AUTO_SCREEN_SCALE_FACTOR=1 it doesn’t stick. I tried in the .desktop file, in user profile and env scripts, systemwide, etc… :frowning: