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