HowTo: Scale Qt application KeePassXC

Posted . Visible to the public.

If you have a notebook with WQHD-display the scaling of Qt applications could be negatively affected. E.g. the KeepassXC icons and text could be rendered so large that KeePassXC is not usable and there aren't settings in the application for downscaling.

Fix with a .desktop file

The scaling of virtualbox, vlc and zoom wasn't an issue, therefore this fix is only for KeepassXC. The application was installed with snap, but the principle is the same when installed differently. Copy your keepassxc_keepassxc.desktop file in /var/lib/snapd/desktop/applications to ~/.local/share/applications. Then change the line with Exec and add your Qt scaling parameters. With QT_AUTO_SCREEN_SCALE_FACTOR=0 automatic scaling can be disabled Show archive.org snapshot . Now it is also possible to add your own scale factors with QT_SCREEN_SCALE_FACTORS=0.9, but that wasn't necessary in this case.

[Desktop Entry]
...
# Exec=env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/keepassxc_keepassxc.desktop /snap/bin/keepassxc %f
Exec=env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/keepassxc_keepassxc.desktop QT_AUTO_SCREEN_SCALE_FACTOR=0 /snap/bin/keepassxc %f
...

To test your factors you can use your notebook with an external monitor and start KeepassXC or other Qt applications from your terminal:

$ QT_AUTO_SCREEN_SCALE_FACTOR=0 QT_SCREEN_SCALE_FACTORS=0.9 keepassxc

Wayland

If you are using wayland (in combination with fractional scaling) another possibility might be forcing the use of X11 or GTK themes Show archive.org snapshot for your Qt applications in the wayland session. For this install e.g. the qt5ct package and add a configuration for systemd user environment variables Show archive.org snapshot (e.g. ~/.config/environment.d/10-qt.conf) with the Qt theme you want:

QT_QPA_PLATFORMTHEME="qt5ct"
# QT_QPA_PLATFORM="xcb" for X11

You can use the theme in combination with the aforementioned scaling factors.

Simon Hofmann
Last edit
Simon Hofmann
Keywords
Qt, KeePassXC, WQHD, Wayland
License
Source code in this card is licensed under the MIT License.
Posted by Simon Hofmann to makandra orga (2022-03-04 11:09)