Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-35701

QScreen physicalDotsPerInch unreliable on Android

    XMLWordPrintable

Details

    • Android

    Description

      QScreen physicalDotsPerInch is unreliable on Android.
      I deployed an application onto a Nexus 10 and a Nexus 4, both which have similar pixel densities (300 and 320, respectively). The values I get for the Nexus 4 are totally inaccurate.

      I used an Android app [1] which gives me the values Android knows of and created a test QML app and tried it on various devices (Nexus 4, Nexus 7 2012 and Nexus 10). Here is the results:

      Let screen be qApp->primaryScreen()

      My Desktop Computer (20" 1680x1050)
      screen->physicalDotsPerInch() = 98.66371567872721 (correct!)
      screen->physicalDotsPerInchX() = 98.54965357967667
      screen->physicalDotsPerInchY() = 98.77777777777777
      screen->physicalSize().width() = 433
      screen->physicalSize().height() = 270
      screen->geometry().width() = 1680
      screen->geometry().height() = 1050

      Nexus 4 (4,7" 1280x768)
      This device as onscreen navigational keys which take around 100px of vertical space which is not available to the application
      DPI Screen Info App:
      Screen width: 768
      Screen height: 1184
      Screen density: 2.0
      Screen density DPI: 320 (DENSITY_XHIGH)
      screen->physicalDotsPerInch() = 163.48531876138432 (wrong!)
      screen->physicalDotsPerInchX() = 159.89508196721312
      screen->physicalDotsPerInchY() = 167.07555555555555
      screen->physicalSize().width() = 122 (I measured about 62mm)
      screen->physicalSize().height() = 180 (I measured about 90mm with system chrome, 105mm for the entire screen)
      screen->geometry().width() = 768
      screen->geometry().height() = 1184

      As you can see here, the physical size of the device is exactly 50% of what it should be, which results in the wrong (halved) DPI.

      Nexus 10 (10,055" 2560x1600)
      DPI Screen Info App:
      Screen width: 2560
      Screen height: 1504
      Screen density: 2.0
      Screen density DPI: 320 (DENSITY_XHIGH)
      screen->physicalDotsPerInch() = 298.055355661438296 (correct!)
      screen->physicalDotsPerInchX() = 298.27522935779814
      screen->physicalDotsPerInchY() = 297.8354838709677
      screen->physicalSize().width() = 218 (I measured about 215mm)
      screen->physicalSize().height() = 124 (I measured about 125mm with system chrome, 137mm for the entire screen)
      screen->geometry().width() = 2560
      screen->geometry().height() = 1454

      As you can see, the values reported for the Nexus 10 are really accurate.

      Nexus 7 (7" 1280x800)
      DPI Screen Info App:
      Screen width: 2560
      Screen height: 1504
      Screen density: 2.0
      Screen density DPI: 320 (DENSITY_XHIGH)
      screen->physicalDotsPerInch() = 198.26257796257798 (correct!)
      screen->physicalDotsPerInchX() = 195.3846153846154
      screen->physicalDotsPerInchY() = 201.14054054054054
      screen->physicalSize().width() = 104 (I measured about 93mm)
      screen->physicalSize().height() = 148 (I measured about 137mm with system chrome, 150mm for the entire screen)
      screen->geometry().width() = 800
      screen->geometry().height() = 1172

      [1] https://play.google.com/store/apps/details?id=com.tspmobile.dpiscreeninfo

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            piotrmi Piotr Mikolajczyk
            broulik Kai Uwe Broulik
            Votes:
            34 Vote for this issue
            Watchers:
            39 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes