Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Screen scaling on Android

Screen scaling on Android

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 2.4k 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.
  • M Offline
    M Offline
    miscreant
    wrote on last edited by
    #1

    So recently I decided to check out Qt Quick for Android and I've been having a problem getting things to scale correctly for different screen sizes.

    From what I've seen in the documentation, the way Qt Quick usually handles different screen resolutions/dpi levels is that the root element is scaled to full screen and then everything else will be scaled accordingly since all measurements are made relative to the root rectangle. However, whenever I run any of the example programs on my phone or in an Android emulator the program will seem to ignore the size specified in the root widget and will do all other measurements for size and position of widgets relative to the actual dimensions of the screen, which makes text practically unreadable on phones with high dpi displays.

    Here's a screenshot of the tweetsearch app running on my computer and then on my phone (Motorola Moto G, 720x1280 4.5" display).
    !https://dl.dropboxusercontent.com/u/65079217/Screenshot-tweetsearch.png!
    !https://dl.dropboxusercontent.com/u/65079217/Screenshot_2014-02-24-12-28-08.png!

    Ideally I'l like the proportions of all the widgets on the Android version would be the same as the Windows version, even though they're running at different resolutions.

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jens
      wrote on last edited by
      #2

      You can make dpi related calculations by dividing all sizes by Screen.pixelDensity. This way controls will keep a constant physical size across multiple screen sizes.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        miscreant
        wrote on last edited by
        #3

        Thanks for that suggestion. I tried out multiplying everything by Screen.pixelDensity, which does work to an extent, but it still doesn't feel like the best solution since I have to add " * Screen.pixelDensity" after every single measurement, which is particularly awkward since it means I have to manually update everything after I make any changes in the designer. Also, since Screen.pixelDensity returns the number of pixels per millimeter it's slightly more complicated to use than say, the system CSS uses where certain devices just have a dpi scale muliplier.

        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