Important: Please read the Qt Code of Conduct -

Screen.pixelDensity vs Screen.logicalPixelDensity

  • 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
    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?

Log in to reply