Disable Qt DPI awareness



  • 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... :(



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



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



  • 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.


  • 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..



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


Log in to reply
 

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