[英]How to interpret QFontMetrics results?
I have a problem making sense of the values I get from QFontMetrics
我在理解从
QFontMetrics
获得的值时遇到QFontMetrics
// 43 characters 0123456789012345678901234567890123456789012
static const QString s("The quick brown fox jumps over the lazy dog");
// Hint: basically returns w->fontMetrics(); with w being my main application window
const QFontMetrics fm = CGuiUtility::currentFontMetrics();
const int w = fm.width(s);
const int h = fm.height();
return QSize(w, h);
With the following screen resolutions I get: 使用以下屏幕分辨率,我得到:
qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1")
qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1")
My understanding is that I do get pixel width/height. 我的理解是,我确实获得了像素的宽度/高度。 I wonder why I get a so much smaller height with a hires resolution (see 2).
我想知道为什么我的租用分辨率要小得多(参见2)。 I would rather expect it the other way around - using more pixels.
我宁愿反过来-使用更多像素。
What I can see is that there is (almost) factor 2 between 1 and 3, which makes sense. 我看到的是(几乎)因子2在1和3之间,这是有道理的。 But then (using 3, no DPI support) the UI is unreadable (too small because of hi DPI screen).
但是,然后(使用3,没有DPI支持)UI无法读取(由于显示DPI屏幕太小,所以太小)。 So how does 2 fit in, which has some odd results.
那么2如何拟合,结果有些奇怪。
Is anybody able to give a hint on the interpretation of those values? 有人能暗示这些价值观的解释吗?
Remark: Related to Style sheets / Qt Designer support for high dpi screens? 备注:与样式表/ Qt Designer对高dpi屏幕的支持有关吗? What I try to find is a reasonable width/height for my UI window on different resolutions/platforms
我试图找到的是在不同分辨率/平台上的UI窗口的合理宽度/高度
Good comments, I see. 好的评论,我明白了。 With hi-dpi Qt scales 1:3 using a "virtual screen" of 1280/780.
对于高dpi的Qt,使用1280/780的“虚拟屏幕”可按1:3缩放比例。 I wonder if I can adjust that pixel ratio manually.
我想知道是否可以手动调整像素比例。 In my very case it happens by setting
qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1")
. 就我而言,这是通过设置
qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1")
。 Is there a chance to set it to 2:1? 是否有机会将其设置为2:1?
Based on the hints of AlexanderVX and SteackOverflow it is clear now. 根据AlexanderVX和SteackOverflow的提示,现在很清楚。
Therefor I close the topiy 因此我关闭了顶部
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.