Important: Please read the Qt Code of Conduct -

QML can't set size by DP on Android

  • Below code display as expected on IPhone retina,
    But it set physical pixel to image on Android.

    Thanks for your help!

    PS: QT5.5

        Image {
            id: image1
            x: 130
            y: 50
            width: 100
            height: 100
            fillMode: Image.PreserveAspectFit
            source: "animal68.svg"

  • It can be fixed by define:

    Density = Screen.pixelDensity * 2.54 / 16

    x = 130 * Density
    width = 100 * Density

    But for IOS , the Screen.pixelDensity mean POINT but pixel, it's really confused.
    So, there are three branchs at least, for ios/mac, for android and for other desktop, more branches maybe.

Log in to reply