I don't know why that variable exists. It's useless as far as I can tell. Maybe 
it means that you are being scaled?

I use Screen.pixelDensity. Which varies as you think it should, but is spec'd 
in px per mm, not DPI.

That pixelRatio is either 1 or 0, I don't think it is ever in between. In 
theory on a 2x device the pixelDenisty will be 2x the 1x.
Meanwhile pixel ratio is:
old (10yr) monitor: 4.x
Samsung Note 2: 10.x
Moto X: 16.x



> Sent: Thursday, February 05, 2015 at 5:29 PM
> From: "John Weeks" <j...@wavemetrics.com>
> To: "interest@qt-project.org" <interest@qt-project.org>
> Subject: [Interest] hi-res drawing on Windows
>
> Is there a comprehensive overview of drawing for monitors at various 
> resolutions on Windows?
> 
> I am trying to get our application to work correctly on a hi-res monitor on 
> Windows. In particular, I have a QToolButton-derived class that makes a 
> button that is just the icon, with no visible frame. It overrides sizeHint(), 
> maximumSize() and paintEvent() to do this. Instances of the button are given 
> icons from PNG resources that have  both standard and "@2x" versions.
> 
> One point of this class is to size the button based on the size of the icon. 
> Thus, sizeHint() and maximumSize() both return iconSize(). In the 
> paintEvent(), I get the icon out of the button using icon(), get the QWindow 
> for the window hosting the button and then use QIcon::pixmap(QWindow *, 
> iconSize(), ...) to get the appropriate QPixmap to draw.
> 
> On Macintosh this works great. On my 5k iMac I get the correct size and 
> hi-res pixmap. Slide the window over to my external standard-res monitor and 
> it redraws with the standard res pixmap.
> 
> On Windows, I don't have a hi-res monitor. I'm faking it by setting "Change 
> the size of all items" to Larger 150%. That's another way to say, "Make my 
> large monitor small" :) Not ideal, and it's not 2x, so I don't really expect 
> the 2x icons. What I DO expect is the QWindow::devicePixelRatio() might 
> return 1.5, but all I get is 1.0 at all settings of "size of all items".
> 
> I found this:
> http://doc-snapshot.qt-project.org/qt5-5.4/highdpi.html
> 
> Since I'm on Windows 8.1 I should be in "Per-Monitor DPI Aware" mode. It 
> seems like I shouldn't have to intervene in order to get 
> resolution-independent pixel drawing.
> 
> If I do this before creating my QApplication instance:
> qputenv("QT_DEVICE_PIXEL_RATIO", "2")
> then I get 2.0 from devicePixelRatio(), as expected. I also get my hi-res 
> icons.
> 
> If I do this instead:
> qputenv("QT_DEVICE_PIXEL_RATIO", "1.5")
> then devicePixelRatio returns 1.0, not 1.5.
> 
> And it doesn't seem like I should have to set this myself, anyway.
> 
> Thanks for any insight you might be able to offer!
> 
> -John Weeks
> 
> _______________________________________________
> Interest mailing list
> Interest@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
> 
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to