9

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?

2 Answers 2

10

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.

-1

I'm not 100% sure, but I think physical resolution - is the actual resolution of the canvas you are painting on. logical resolution - is the resolution you use in your program. For example to handle different screens you may say that for any physical resolution of the display (canvas) I will work with logical resolution 100 per 100 pixels and use fixed layout for example. Rescaling will be done by the painter automatically using physical resolution

OpenGL works this way, for example. It first transforms all coordinates (using model, view, projection matrices) into a [-1, 1] range cube, performs calculations in these coords and later maps them to actual color buffer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.