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. Screen.Size questions
Qt 6.11 is out! See what's new in the release blog

Screen.Size questions

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
2 Posts 2 Posters 1.6k Views 1 Watching
  • 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.
  • carles.sole.grauC Offline
    carles.sole.grauC Offline
    carles.sole.grau
    wrote on last edited by
    #1

    Hi everybody,
    when developing in Qt QML there is an object called Screen that is useful to size some items (http://doc.qt.io/qt-5/qml-qtquick-window-screen.html). But there is something that I don't understand at all.

    I have a One Plus X, its width specs are (https://oneplus.net/es/x/specs)
    Width in physical PIXELS: 1080 pixels
    Width in mm: 69 mm (so the screen a little bit less)

    So when I run this part of code:

    console.log("Width in pixels: " + Screen.width)
    console.log("Pixel Ratio: " + Screen.devicePixelRatio )
    

    It returns me

    qml: Width in pixels: 360
    qml: Pixel Ratio: 3
    

    So I understant that Screen.width returns he width in logical pixels:

    Device Pixel Ratio: The ratio between physical pixels and device-independent pixels for the screen.
    So:

    360 logical pixels = 1080 pyhisical pixels * 1 logical pixel/3 pyhisical pixels
    

    And in documentation it is called that the property pixelDensity:
    Pixel Density: The number of physical pixels per millimeter.
    But if I check this:

    console.log("Pixel Density: " + Screen.pixelDensity )
    
    qml: Pixel Density: 5.786108689334496
    

    It returns a density that NOT corresponds in the density of physical pixels because

    **1080** physical pixels / **5.78** physical pixels/mm = 186.85 mm
    

    And the width IS NOT 186.85, instead of that:

    **360** logical pixels / **5.78** logical pixels/mm = 62,28 mm
    

    That it match with the with of my device.

    So... The pixel density documentation is not OK?

    It would be: (The number of physical logical pixels per millimeter) ?

    Thank you very much

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by A Former User
      #2

      Hi! Looking at qquickscreen.cpp, it's not a documentation bug:

      qreal QQuickScreenInfo::pixelDensity() const
      {
          if (!m_screen)
              return 0.0;
          return m_screen->physicalDotsPerInch() / 25.4;
      }
      

      So it must be something else, maybe a bug in some driver or in the platform abstraction layer for your particular device. I'd recommend to file a bug, https://bugreports.qt.io.

      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