Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-62649

Determine Physical DPI API behavior

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Won't Do
    • Icon: Not Evaluated Not Evaluated
    • None
    • None
    • Other
    • None

      Qt has API for querying physical DPI:

      QPaintDevice::physicalDpiX()
      QPaintDevice::physicalDpiY()
      QScreen::physicalDotsPerInch()
      Quick: Screen.pixelDensity
      

      Which are documented to return the number of physical pixels per inch/millimeter. This was simple, until the introduction of the logical pixels (device independent pixels). Now there are two behavior options:

      1) The API returns a constant value: display physical dots per inch

      This value does not change if/when the device pixel ratio changes. Physical dots per inch is, after all, a physical (constant) property of the display. It is reasonable that an API that previously returned a hardware characteristic continues to report the same value, independent of the software configuration.

      2) The API returns a value suitable for creating physically sized UI: the number of logical pixels per mm (or inch)

      The value is divided by the device pixel ratio internally. This enables writing code like this:

      item.with = 2 * Screen.pixelDensity
      

      The item will now be two mm across on all displays (provided the display provides accurate physical measurements). The above code works on dpr == 1 displays; it is reasonable to expect that it continues to do so on other displays.

      Qt Currently implements option 2. A patch for changing it to option 1 is here: https://codereview.qt-project.org/#/c/161333/

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            sorvig Morten Sørvig
            sorvig Morten Sørvig
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes