[Interest] Changes in Qt 5.6 on Windows HiDPI

Pavlo Dyachenko ppaveld at yahoo.ie
Tue Nov 17 22:38:12 CET 2015


I believe the problem is with QT incorrectly determining scaling ratios for each monitor on Windows. When I briefly looked at the code, from what I remember anyway, it seemed it used physical pixel density to calculate the ratio. What it should use is Window's logical DPI for each monitor. Can be acquired by simple call to 

GetDpiForMonitor (Win 8.1+, different API for older versions), i.e. no complex density calculations are necessary for Windows.
OS automatically scales all point sized fonts to whatever value is specified in monitor settings, it makes sense for QT to resize all of its widgets to exact same ratio, not some ratio calculated from density. After all, I can have an ordinary low DPI monitor, but due to visual impairment have my settings set to 125-150%, in which case I'd expect my window get proportionally bigger. This is how ALL Windows applications behave.


Luckily there is a workaround, just set QT_SCREEN_SCALE_FACTORS by using qputenv with the semicolon separated list of scaling ratios for your monitors. We did just that and it works really well. After that you should get correct values from devicePixelRatio() etc.

Regards,
Pavlo

On Monday, 16 November 2015, 20:11:36, Adam Light <aclight at gmail.com> wrote:







On Thu, Nov 12, 2015 at 3:49 PM, Adam Light <aclight at gmail.com> wrote:

We've just started testing our application using Qt 5.6 (self built from Nov. 10 git checkout).
>
>
>It appears that the behavior of QDesktopWidget::logicalDpiX (and Y) has changed since Qt 5.5.
>
>
>We bought a Dell Inspiron 15 laptop with a High DPI display. If I open Control Panel, choose Display, and click the "set a custom scaling level" link, the scaling factor was set to 250% out of the box. When we run our application and call QApplication::desktop()->logicalDpiX(), the value returned is 80. Using Qt 5.5, that would have returned 240 (2.5 * 96).
>
>
>Is this change intentional? This change breaks a lot of the drawing code in our application, and so I'd like to know whether we need to adapt our application or if I should report this as a bug.
>
>
>Additionally, I notice that if I call QApplication::desktop()->devicePixelRatioF(), the returned value is 3. I would expect that 2.5 is returned.

For what it's worth, I've just created https://bugreports.qt.io/browse/QTBUG-49465 for the devicePixelRatioF() issue, since I'm pretty sure that's a bug.


Adam


_______________________________________________
Interest mailing list
Interest at qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest



More information about the Interest mailing list