[Interest] How to read screen information from QGuiApplication to put in qputenv environment variable?

Tor Arne Vestbø Tor.arne.Vestbo at qt.io
Mon Feb 15 13:54:58 CET 2021

> On 15 Feb 2021, at 13:48, Anisha kaul <anisha.kaul.1983 at gmail.com> wrote:
> Well, thank you for the response and for the idea about creation and deletion of objects. I tried it and it worked.
> I am feeling though that it is not a good way of writing code.
> Am I trying to solve a wrong problem?
> My aim is to run this application on screens of different PPI. So, I thought that I can get the PPI and set the scale accordingly.
> Any other suggestions about some proper way to solve this?

Qt Quick already takes care of this for you. And if you need to get the scale factory manually, it’s available via QWindow::devicePixelRatio().

You should use this. That will work on OSes that tweak DPI, as well as OS’es that don’t. 

Do not use QT_SCALE_FACTOR for anything but testing.

Tor Arne 

More information about the Interest mailing list