如何解释 QFontMetrics 结果? [英] How to interpret QFontMetrics results?

查看:72
本文介绍了如何解释 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:

  1. ) 1920/1080: 256/16
  2. ) 3840/2160: 178/10 hi DPI 支持 qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1")
  3. ) 3840/2160: 536/32 没有高 DPI 支持

我的理解是我确实得到了像素宽度/高度.我想知道为什么我在雇佣决议中得到了如此小的高度(见 2).我宁愿期望它反过来 - 使用更多像素.

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). I would rather expect it the other way around - using more pixels.

我能看到的是,1 到 3 之间(几乎)有因子 2,这是有道理的.但是随后(使用 3,不支持 DPI)UI 不可读(因为 hi DPI 屏幕太小).那么 2 是如何适应的,这会产生一些奇怪的结果.

What I can see is that there is (almost) factor 2 between 1 and 3, which makes sense. But then (using 3, no DPI support) the UI is unreadable (too small because of hi DPI screen). So how does 2 fit in, which has some odd results.

有人能就这些值的解释给出提示吗?

Is anybody able to give a hint on the interpretation of those values?

备注:与样式表/Qt Designer 对高dpi 屏幕的支持有关? 我试图找到的是合理的我的 UI 窗口在不同分辨率/平台上的宽度/高度

Remark: Related to Style sheets / Qt Designer support for high dpi screens? What I try to find is a reasonable width/height for my UI window on different resolutions/platforms

好的评论,我明白了.高 dpi Qt 使用 1280/780 的虚拟屏幕"按 1:3 比例缩放.我想知道我是否可以手动调整该像素比率.就我而言,它是通过设置 qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1") 来实现的.有机会设置成2:1吗?

Good comments, I see. With hi-dpi Qt scales 1:3 using a "virtual screen" of 1280/780. 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"). Is there a chance to set it to 2:1?

  1. ) "桌面 w1920 w1080 - 比率:1 | 80 个字符:w560 h16 | 43 个字符:w256 h16"
  2. ) 桌面 w1280 w720 hi DPI 比率:3 | 80 个字符:w400 h10 | 43 个字符:w178 h10"
  3. ) "桌面 w3840 w2160 - 比率:1 | 80 个字符:w1200 h32 | 43 个字符:w536 h32"

推荐答案

基于 AlexanderVX 和 SteackOverflow 的提示,现在很清楚了.

Based on the hints of AlexanderVX and SteackOverflow it is clear now.

  1. "桌面 w1920 w1080 - 比率:1 | 80 个字符:w560 h16 | 43 个字符:w256 h16"
  2. 桌面 w1280 w720 hi DPI 比率:3 | 80 个字符:w400 h10 |43 个字符:w178 h10"
  3. "桌面 w3840 w2160 - 比例:1 | 80 个字符:w1200 h32 |43 个字符:w536 h32"

因此我关闭了主题

这篇关于如何解释 QFontMetrics 结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆