Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to get true, accurate DPI values for monitor?
Forum Updated to NodeBB v4.3 + New Features

How to get true, accurate DPI values for monitor?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 226 Views 2 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.
  • P Offline
    P Offline
    Publicnamer
    wrote on last edited by
    #1

    When I obtain the DPI values programmatically like so:

            int dpiX = app->desktop()->logicalDpiX();
            int dpiY = app->desktop()->logicalDpiY();
    

    ... I find that the values are simply the ones that I set in Xfce's Appearance settings. That is fine, except in order to accurately detect whether my code is running on a phone (e.g. PinePhone) versus a desktop/laptop, I need a hardware-based DPI value.

    How can I get the true, accurate DPI values for monitor programmatically?

    Pl45m4P 1 Reply Last reply
    0
    • P Publicnamer

      When I obtain the DPI values programmatically like so:

              int dpiX = app->desktop()->logicalDpiX();
              int dpiY = app->desktop()->logicalDpiY();
      

      ... I find that the values are simply the ones that I set in Xfce's Appearance settings. That is fine, except in order to accurately detect whether my code is running on a phone (e.g. PinePhone) versus a desktop/laptop, I need a hardware-based DPI value.

      How can I get the true, accurate DPI values for monitor programmatically?

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by
      #2

      @Publicnamer

      Try physicalDotsPerInch() if you are using QScreen

      https://doc.qt.io/qt-5/qscreen.html#physicalDotsPerInch-prop


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      1 Reply Last reply
      0
      • Kent-DorfmanK Offline
        Kent-DorfmanK Offline
        Kent-Dorfman
        wrote on last edited by Kent-Dorfman
        #3

        look in your Xorg.0.log file for the EDID data. As far as consistently getting monitor DPI in all cases...you can't. in many cases its broken by design.

        https://xorg.freedesktop.narkive.com/UkAoI71R/how-to-read-edid-xrandr

        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