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

Screen.pixelDensity vs Screen.logicalPixelDensity

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 1.3k 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.
  • T Offline
    T Offline
    TT_NBE
    wrote on last edited by
    #1

    Hello,

    I'm polishin the layout of my app and I would like to set the size of items the same (in millimeters) across different platforms (currently I can test on Windows and android).

    The setup is simple
    @import QtQuick 2.0
    import QtQuick.Window 2.0
    Item
    {
    height:15*Screen.logicalPixelDensity //this works on windows
    ....
    }@

    On window this is perfect, the item is 1.5 cm high

    On android (or at least my android device) the items are smaller, but I can get it to work perfectly by replacing the Screen.logicalPixelDensity with Screen.pixelDensity.

    But if I use Screen.pixelDensity than items are too small on Windows.

    So should I try to figure out the platform at runtime and use a javascript function to calculate the height based on that platform? Or is there a better option?

    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