Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Disable Qt DPI awareness

    General and Desktop
    3
    6
    5235
    Loading More Posts
    • 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.
    • W
      wjlrkjjv last edited by

      Hello,

      I'd like to change Qts behavior to render in fixed size (pixels) and be scaled up by the OS (Windows).
      Is it possible?

      Why? Because:
      I want to render some small icons inside a QListWidgetItem (via delegate) but I just don't know how to deal with high dpi.
      If I change the widget item sizeHint to 20 for example, it will be in pixels and on high dpi, text will be larger and outside the widget item which is 20 pixels in height.
      By what value do I have to multiply these 20 pixels? And how do I draw the icon so that it always fits the height?

      I'm just too confused... :(

      1 Reply Last reply Reply Quote 0
      • W
        wjlrkjjv last edited by

        QMainWindow::devicePixelRatio() always returns 1 (I changed windows dpi to 150%).
        Why is the return type int and not double?

        1 Reply Last reply Reply Quote 0
        • W
          wjlrkjjv last edited by

          Noone knows how to draw dpi aware or disable it and let windows scale?

          1 Reply Last reply Reply Quote 0
          • T
            timday last edited by

            I don't think QMainWindow::devicePixelRatio() does what you think it does. I'm not sure I know what it does either, but since it says "Common values are 1.0 on normal displays and 2.0 on Apple "retina" displays." I wouldn't worry about it until I was trying to understand some issues with some goofy HW like a retina display (which I believe can report some not-technically-correct numbers for resolution etc, for backwards compatibility reasons).

            What I think you should actually be looking at is:

            • Get hold of the screen your window is on with QWindow::screen()
            • Query physicalDotsPerInch or logicalDotsPerInch as appropriate for what you're doing (note there are X Y versions too!); see the Detailed Description section for more info what the difference is.
            1 Reply Last reply Reply Quote 0
            • W
              wjlrkjjv last edited by

              Thank you!

              Is it possible to tell Qt to draw in pixels and ignore the windows DPI setting?
              Even with a DPI manifest set to non-aware, Qt still scales and no scaling by windows occurs..

              1 Reply Last reply Reply Quote 0
              • Q
                qtacc32 last edited by qtacc32

                It's possible by setting the manifest to "None" and specifying "-platform windows:dpiawareness=0" as startup parameter.

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post