Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Not getting correct device resolution using Qml's `Screen`
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
4 Posts 3 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Ben SB Offline
    Ben SB Offline
    Ben S
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    2
    • Ben SB Offline
      Ben SB Offline
      Ben S
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      1
      • E Offline
        E Offline
        EMC3
        wrote on last edited by
        #3

        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?

        H 1 Reply Last reply
        0
        • E EMC3

          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?

          H Offline
          H Offline
          Hitokage
          wrote on last edited by
          #4

          @EMC3 I think it's caused by this:

          QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
          
          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved