[Interest] How to detect a HiDPI display with Qt?

Thiago Macieira thiago.macieira at intel.com
Mon Mar 18 22:45:04 CET 2019


On Monday, 18 March 2019 09:59:36 PDT Vadim Peretokin wrote:
> I'm not clear on how to detect if a display is HiDPI with Qt. I've tried
> QApplication.desktop()->screen()->devicePixelRatio() but even that returns
> 1 for a display that is 3840x2160.

That is the correct way. The problem is that the display in question is 
misconfigured.

qtdiag reports for me:

# 1 "DP1-1" Depth: 24 Primary: no
[...]
  Geometry: 1920x1080+3200+0 (native: 3840x2160+3200+0) Available: 
1920x1080+3200+0
  Virtual geometry: 5120x1080+0+0 Available: 5120x1080+0+0
  2 virtual siblings
  Physical size: 600x340 mm  Refresh: 30 Hz Power state: 0
  Physical DPI: 81.28,80.6824 Logical DPI: 108.373,108.427 (native: 
216.747,216.854) Subpixel_None
  High DPI scaling factor: 2 DevicePixelRatio: 2 Pixel density: 2
  Primary orientation: 2 Orientation: 2 Native orientation: 0 
OrientationUpdateMask: 0

Source (qtdiag.cpp):

        str << "DevicePixelRatio: " << screen->devicePixelRatio()
            << " Pixel density: " << platformScreen->pixelDensity();

This is with QT_AUTO_SCREEN_SCALE_FACTOR=1
-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel System Software Products






More information about the Interest mailing list