11

I run Gnome, which has pretty good support for my HiDPI screen. However, when I run QT apps I can't seem to find a way to scale the fonts. Is there a way to do this without installing a full version of KDE?

6

Updated:

Since Qt 5.6, Qt 5 applications can be instructed to honor screen DPI by setting the QT_AUTO_SCREEN_SCALE_FACTOR environment variable. If automatic detection of DPI does not produce the desired effect, scaling can be set manually per-screen (QT_SCREEN_SCALE_FACTORS) or globally (QT_SCALE_FACTOR). You can also use QT_FONT_DPI to adjust scaling of text.

Original:

You can try this recipe from the archwiki

Qt5 applications can often be run at higher dpi by setting the QT_DEVICE_PIXEL_RATIO environment variable. Note that the variable has to be set to a whole integer, so setting it to 1.5 will not work.

This can for instance be enabled by creating a file /etc/profile.d/qt-hidpi.sh

export QT_DEVICE_PIXEL_RATIO=2

And set the executable bit on it.

11

QT_DEVICE_PIXEL_RATIO is deprecated since 5.4; instead, use QT_SCALE_FACTOR. I use it, setting it to 1.5, with good results (e.g., VirtualBox 5.1)

4

QT automatically scales the font based on the screen's DPI:

The traditional approach to supporting high DPI has been one where Qt scaled fonts automatically [...]

I had the problem that my screen has 166 dpi, but the font sizes chosen by Qt were much too large. Luckily, there is a way to tell Qt to assume a smaller value by setting QT_FONT_DPI. For me, 128 is nice.

(I'm using cinnamon as desktop environment, and it pushes the configured font sizes for Gtk 1:1 to Qt, which is what brings this issue)

1
  • This works better than any other Qt setting, and you can use it inline when you run an app to tune as needed, eg: QT_FONT_DPI=128 bin/robo3t & – moodboom Jan 29 '20 at 15:40
1

I had the problem, that apps like KeepassXC and VLC have tiny, unreadable fonts now in Linux Mint 20 Ulyana (Cinnamon Edition). To make my QT-Apps look normal, I needed both solutions mentioned here and put following lines into /etc/profile.d/qt-fix.sh:

# For the graphical elements
export QT_SCALE_FACTOR=1.5 

# To make the fonts readable
export QT_FONT_DPI=96

Although I read, that QT scales automatically, scaling only the fonts lead to strange look with unexpected line breaks.

0
'export QT_DEVICE_PIXEL_RATIO=2'

is deprecated.

Instead use:

export QT_AUTO_SCREEN_SCALE_FACTOR=1  

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.