Qt/QML 5.15.5 How to set logical DPI to 96
-
On my system, Windows 10, I have a logical DPI of 96 and a physical of 141.???. I am developing for a Linux embedded device with a 133 physical DPI. The logical is also 133. This is problematic as our font settings/all our text is showing up way too big on the target.
How can we set the logical DPI?
Also, we are using boot2qt, the configuration of which is not something I have access to, but if a setting is required in there to insure that a virtual screen representation will be used for Qt applications, so be it. Or if I can append an environment variable setting to the launch command to set it appropriately, that would work.
Reminder, we are using Qt/QML 5.15.5. And, yes, I am aware that 6 does seem to have better features to do this.
Thanks in advance for any help.
-
It would appear to be that there is an environment variable that will do this, not perfectly, but certainly vastly better than previously. Sadly, the very limited documentation on it implies it is only something for development purposes, presenting a clumsy way to look at your app using different DPI settings.
The following, placed in main.cpp, worked. Yes, it could be set in the environment as well, having first tested it as a .profile entry.
qputenv("QT_FONT_DPI", QByteArray("96"));
96 DPI is just a reference value on which Qt should be doing the appropriate scaling internally. It could be almost anything and still achieve the same results. Virtual pixels are obviously used for GUI components, why not consistently for the fonts.
Though we are seeing what appears like a font substitution as well. Best guess is that Arial is being substituted for Liberation Sans, even though Liberation Sans is installed on all systems and is specifically loaded by the application. For example, the zero is much narrower on my system than on the target, as is the case of the zero in Arial as opposed to Liberation Sans.