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. QML can't set size by DP on Android

QML can't set size by DP on Android

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 1 Posters 1.1k Views
  • 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 Offline
    F Offline
    felix99
    wrote on last edited by felix99
    #1

    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
    0
    • F 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 Offline
      F Offline
      felix99
      wrote on last edited by
      #2

      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
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved