更新时间:2023-01-26 10:49:34
使用固定坐标和大小的应用程序在高 DPI 分辨率下看起来很小.尽管即使使用布局也存在一些关于元素和字体大小和边距的问题.幸运的是,从 Qt 5.4 开始就支持高 DPI 显示,因为已经有许多 高 DPI 问题修复.
Applications that use fixed coordinates and sizes will look small on high-DPI resolutions. Although even if using layouts there are some issues regarding element and font sizes and margins. Fortunately there is support for high-DPI displays since Qt 5.4 as there has been many high-DPI issue fixes.
Windows 上的应用程序可以采用以下DPI Awareness"级别之一(来自 Qt 文档):
An application on Windows can assume one of the following levels of "DPI Awareness" (From the Qt documentation) :
它还指出:
默认情况下,Qt 应用程序在 Windows 8.1 或旧版 Windows 上的系统 DPI 感知.从 Qt 5.4 开始,级别可以通过将参数传递给平台插件来指定(请参阅使用 qt.conf):
Qt applications by default are Per-Monitor DPI Aware on Windows 8.1 or System-DPI Aware on older versions of Windows. As of Qt 5.4, the level can be specified by passing a parameter to the platform plugin (see Using qt.conf):
<application> -platform windows:dpiawareness=0,1,2
您可以在此处阅读更多信息.
You can read more information here.
一般来说,要在高 DPI 显示器上拥有良好的用户界面,请考虑以下事项:
In general to have a good UI on high-DPI displays, consider the following :
QPainter
和像素图,则设置 Qt::AA_UseHighDpiPixmaps
属性,或计算缩放比例用于在特殊情况下调整某些元素大小.Qt::AA_UseHighDpiPixmaps
attribute if you work with QPainter
and pixmaps, or calculate a scaling ratio for adjusting certain element sizes in special situations.