Important: Please read the Qt Code of Conduct -

Not getting correct device resolution using Qml's `Screen`

  • I'm currently using Qt 6.2.1 & QML to develop a cross platform desktop & mobile app. There a part in the app where I need to get the resolution of the device/screen that's being used. In QML, there is the Screen object. Using its width and height fields on Linux, macOS, and a Kindle Fire 10 in (2020), it worked fine. Even when rotating it updated the width/height to match the orientation as the user would hold the device.

    But when trying it out on my LG Q7+ Android phone, Screen.width=823 and Screen.height=411. This isn't correct. The resolution of my phone is 2160×1080. I also tried this out on an iPad Pro 12.9 in (resolution is 2048x2732), but it also was much smaller than the true pixel width and height.

    Is there something else I need to specify when I start up the app (or in an AndroidManifest.xml or Info.plist)? I remember having to add in CoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling) when I was doing a Qt5 desktop app for a retina display. but in Qt6 this is deprecated.

  • I've found something that's giving me a better result, but not correct either. On my LG Q7+, if I use the Screen.devicePixelRatio field, it's better, but there's still some issues. Eg.:

    Screen.width * Screen.devicePixelRatio = 2160.38
    Screen.height * Screen.devicePixelRatio = 1078.88

  • By playing with widgets on android i found out that the QT Android app is somehow rendered on a lower resolution (the resolution you are reading) ant then scaled up. I found your thread in search for a way to disable this and use the entire native screen resolution. Did you find a solution?

Log in to reply