Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How get the physical dimensions of the device?
Qt 6.11 is out! See what's new in the release blog

How get the physical dimensions of the device?

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
5 Posts 4 Posters 1.3k Views 3 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.
  • T Offline
    T Offline
    Trikrista
    wrote on last edited by
    #1

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

    I'm sorry for my bad English

    1 Reply Last reply
    0
    • D Offline
      D Offline
      ddze
      wrote on last edited by ddze
      #2

      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.

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kolegs
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • A Offline
          A Offline
          Albus
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0
          • T Offline
            T Offline
            Trikrista
            wrote on last edited by
            #5

            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

            I'm sorry for my bad English

            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