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
Forum Update on Tuesday, May 27th 2025

QML can't set size by DP on Android

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 1 Posters 1.1k 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.
  • F Offline
    F Offline
    felix99
    wrote on 24 Jul 2015, 08:16 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 27 Jul 2015, 02:42
    0
    • F felix99
      24 Jul 2015, 08:16

      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 27 Jul 2015, 02:42 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

      2/2

      27 Jul 2015, 02:42

      • Login

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