In the documentation of QPaintDevice
(which all paintable-to entities derive from, such as QWidget
, QPixmap
, etc), there are two functions to receive the DPI of the device
int logicalDpiX() const;
int physicalDpiX() const;
int logicalDpiY() const;
int physicalDpiY() const;
The documentation says
The logicalDpiX() and logicalDpiY() functions return the horizontal and vertical resolution of the device in dots per inch. The physicalDpiX() and physicalDpiY() functions also return the resolution of the device in dots per inch, but note that if the logical and physical resolution differ, the corresponding QPaintEngine must handle the mapping. Finally, the colorCount() function returns the number of different colors available for the paint device.
Despite this description, I still don't understand what the purpose of the difference is. Can someone please shed some light on this?
Logical dots per inch are used to convert font and user interface elements from point sizes to pixel sizes, and might be different from the physical dots per inch.
The QPaintDevice class is the base class of objects that can be painted on with QPainter.
I assume physical is the actual resolution of the device and logical is what the user has set in the os preferences. This is popular with retina or other high resolution displays where using the physical dots for pixels would result in everything being too small.
I found this windows specific information: http://msdn.microsoft.com/en-us/library/windows/apps/ff684173
Because actual pixel sizes vary, text that is readable on one monitor might be too small on another monitor. Also, people have different preferences—some people prefer larger text. For this reason, Windows enables the user to change the DPI setting. For example, if the user sets the display to 144 DPI, a 72-point font is 144 pixels tall. The standard DPI settings are 100% (96 DPI), 125% (120 DPI), and 150% (144 DPI). The user can also apply a custom setting. Starting in Windows 7, DPI is a per-user setting.
Even better: QT docs:
A note on logical vs physical dots per inch: physical DPI is based on the actual physical pixel sizes when available, and is useful for print preview and other cases where it's desirable to know the exact physical dimensions of screen displayed contents. Logical dots per inch are used to convert font and user interface elements from point sizes to pixel sizes, and might be different from the physical dots per inch. The logical dots per inch are sometimes user-settable in the desktop environment's settings panel, to let the user globally control UI and font sizes in different applications.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With