在 QPaintDevice
的文档中(所有paintable-to实体都派生自,例如QWidget
,QPixmap
等),有两个函数接收设备的DPI
int logicalDpiX() const;
int physicalDpiX() const;
int logicalDpiY() const;
int physicalDpiY() const;
文档说
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.
尽管有这样的描述,我还是不明白区别的目的是什么。有人可以解释一下吗?
最佳答案
我假设物理分辨率是设备的实际分辨率,逻辑分辨率是用户在操作系统首选项中设置的分辨率。这在视网膜或其他高分辨率显示器中很流行,在这些显示器中使用物理点作为像素会导致一切都太小。
我找到了这个 windows 特定信息: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.
更好的是: 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.
关于c++ - Qt中的logicalDpiX和physicalDpiX有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16561879/