Working with high DPI
-
Hi all. Even after reading docs on the topic, I do not understand at all how to work with higher DPI. From the docs, I am assuming that the higher-DPI adaptation should happen automatically. But what it creates is just a mess of a GUI. The elements that fit the height of the window stop fitting as soon as I change from 100% to 300% or even 200% scale setting in Win11.
Honestly, I do not even know what to google, I seem to find no information on how to deal with it and how to have interface that reasonably adapts to the DPI change without setting height/width of all elements manually for different DPI values. Are there any resources that you would recommend me to read, apart from the official docs? Why, if GUI looks ok at 100% Scale, it does not look ok at 200% Scale, if the docs claims that in Qt6 the adaptation to DPI should be automatically performed?
-
To give a general answer: the documentation is correct; Qt does handle HiDPI scaling automatically, in the sense that it will ensure that for anything drawn by it each logical pixel measure specified by the application will actually be expanded to the appropriate number of physical pixels according to the display ratio. So if your applications paints a 10x10 rectangle, and DPI scaling is 300%, Qt will draw a 30x30 rectangle.
Note however two things: the first is that Qt cannot do this for things it doe not paint (like the application window frame). The second is that physical pixels are limited by the display resolution, and can't be just conjured out of the air. This means that a each individual element in your UI grows, less of them can fit in the screen.
If your application UI is generally responsive - by properly using layouts (in widgets) and anchors (in QML) - this helps, but only to a degree. In very high scaling factors you'll hit minimum size hints and the like. If you need to support that, then yes - you'll need a different version of the UI optimized for very low resolution, or accommodating by wrapping things in scroll areas or custom layouts that can reflow into multiple lines, etc.