Linux Desktop Users Who Use Qt or KDE Software May Want To Hard-Code QT AUTO SCREEN SCALE FACTOR and XCURSOR SIZE

From LinuxReviews
Jump to navigationJump to search
KDE Katie.png

Programs using recent KDE Frameworks versions combined with recent Qt version like to randomly apply display scaling. The result is that some programs have their fonts and/or icons (depending no KDE Frameworks and Qt version) scaled while others are not scaled. Programs using Qt 5.15.1 also enjoy ignoring the systems mouse pointer size. One solution for anyone using anything using the ridiculously buggy recent Qt and KDE versions is to set QT_AUTO_SCREEN_SCALE_FACTOR to either 0 or 1, depending on your preference, and XCURSOR_SIZE has an environment variable.

written by 윤채경 (Yoon Chae-kyung)  2020-10-01 - last edited 2020-10-01. © CC BY

KDE Icon Sizes.jpg
Two programs using the KDE Frameworks.

Question: Which of the programs in the above screenshot have their toolbar set to a 40px icon size?

The answer is.. BOTH. Both the toolbars have a 40px icon size.

KDE Icon Sizes-close-up.jpg
All of these icons are supposedly 40px. Except.. that the icons on the left are 40px, and the ones on the right are about 75px.

The KDE Plasma desktop environment will set a variable called QT_AUTO_SCREEN_SCALE_FACTOR to QT_AUTO_SCREEN_SCALE_FACTOR=0 for you. Other desktop environments do not, and why would they? This is a special variable used by Qt and KDE programs for scaling.

One small problem with this fine variable that decides of Qt and KDE programs should scale or not is that it is, when unset, either considered to be true or false depending on what program you happen to launch. Some programs behave as if it's QT_AUTO_SCREEN_SCALE_FACTOR=0 and some programs behave as if it's QT_AUTO_SCREEN_SCALE_FACTOR=1 if it's actually unset. The result of a default that is, in practice, QT_AUTO_SCREEN_SCALE_FACTOR=$RANDOM is pretty laughable and it provides a rather inconsistent desktop experience if you're using Qt or KDE programs outside of the KDE Plasma desktop environment.

There are two not very correct ways to fix this:

sudo sh -c 'echo "QT_AUTO_SCREEN_SCALE_FACTOR=0" >> /etc/environment'


sudo sh -c 'echo "export QT_AUTO_SCREEN_SCALE_FACTOR=0" > /etc/profile.d/'

That is, of course, not the only problem with recent Qt+KDE combinations.

How Qt And KDE Decides To Size The Mouse Pointer In Qt 5.15.1

Wonderful KDE mouse pointer consistency Qt 5.15.1 KDE Frameworks 5.73.0.jpg
Which of these mouse pointers are set to 48px? The answer is.. both.

Let's say you've been using Xfce or KDE Plasma for years and you have decided on, and configured, a mouse pointer size and theme. Then one day you "upgrade" to Qt 5.15.0 and your mouse pointer is suddenly tiny in all Qt and KDE applications. What happened? Who knows. That's just Qt professionalism. Or something.

Picking on Qt is kind of mean. After all, Qt 5.15.0 did bring us this very smooth toolbar functionality:

How all Qt and KDE applications linked against Qt 5.15 behave on GNU/Linux under multi-monitor X setups.

The Qt developers did fix the toolbar thing in Qt 5.15.1 but they introduced a brand new problem: The mouse pointer is no longer set to the system-configured size in all Qt and KDE applications. This is a program in the KDE Plasma desktop environment and it is a problem when Qt/KDE software is used on other desktop environments. It is specially laughable in the KDE Plasma desktop environment where the kwin window manager does care what mouse pointer size is set using systemsettings5 while other programs don't. The actual KDE Plasma desktop, and the widgets, also care to some degree. Hoovering the mouse over widgets and some parts of the GUI makes the mouse pointer big while it is small when hoovering over other elements. Open any program and move the mouse pointer within it and it becomes small. The same problem is there in other desktop environments, if you use Xfce and you set a mouse theme and pointer size in xfce4-mouse-settings you get what you asked for in everything but Qt and KDE applications.

A not at all elegant solution to the mess that is Qt 5.15.1 is to hard-code a XCURSOR_SIZE= and set that system-wide:

sudo sh -c 'echo "XCURSOR_SIZE=48" >> /etc/environment'


sudo sh -c 'echo "export XCURSOR_SIZE=48" > /etc/profile.d/'

This solution is obviously laughable and not what you're supposed to do. But it works, and since you can't actually configure a mouse pointer size in systemsettings5 and have it actually be applied anyway.. it's something that does work. Having a properly sized mouse pointer is better than having a tiny one if you want to play interesting KDE games such as "How many mouse clicks does it take to crash a recent version of Plasma Discover?".

Plasma Discover - The KDE Crash Handler.jpg
Plasma Discover 5.19.5 using KDE frameworks 5.73.0 has some issues...

Writing articles like this one about Qt and KDE is a bit sad. KDE Plasma is, after all, the most feature-rich desktop environment there is and KDE applications gives users the choices, and features, they need. A KDE application will have 20 functions where a foot desktop "app" will have 2. 5 of the features in the KDE application will do the same thing and 5 of them will make it crash, but at least they are there, available as a choice. Those choices will become an important advantage if the developers of the Qt library and the KDE frameworks ever decide to make those things stable and usable instead of introducing new annoying bugs in each and every release.

(0 votes)

Add your comment
LinuxReviews welcomes all comments. If you do not want to be anonymous, register or log in. It is free.