Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    QML can't set size by DP on Android

    QML and Qt Quick
    1
    2
    906
    Loading More Posts
    • 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.
    • F
      felix99 last edited by felix99

      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"
          }
      
      F 1 Reply Last reply Reply Quote 0
      • F
        felix99 @felix99 last edited by

        It can be fixed by define:

        Density = Screen.pixelDensity * 2.54 / 16

        Then
        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.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post