How get the physical dimensions of the device?



  • How get the physical dimensions of the device?
    I use QScreen, but it often gives is not the correct data.



  • Have you tried to get dpi for the device first :
    physicalDotsPerInchX : const qreal
    physicalDotsPerInchY : const qreal

    also you may compare or get the dpi of with the QWidget (if you use one)
    int QPaintDevice::physicalDpiX() const
    int QPaintDevice::physicalDpiY() const

    and multiply by the width/height of the device, widget or an item. If you want the size in metric/imperial you need to convert the values.



  • You should be careful with using this methods, in many android devices it gives you false information.



  • How about using Screen.pixelDensity? (with help of Screen.width, height, desktopAvailableHeight, desktopAvailableWidth of course)



  • I have used many ways, including android.util.DisplayMetrics.
    And all they give the wrong dpi, so I can't find the diagonal of the device(
    And qt methods wrong consider the pixels at the start of the program


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.