Qt:字体大小或更确切地说是高度

发布于 2024-12-23 09:11:44 字数 246 浏览 1 评论 0原文

我正在绘制一个固定条带,高度为 50 像素,宽度与我的应用程序主窗口一样。

我想在该条上放置文字。

我的问题是,即使使用相同的字体和大小(例如 arial 15),字体在 OSX 和 Windows 下也会有不同的高度。

有没有办法让这变得更加可预测?我知道我可以使用 QFont 测量机制,直到我需要的文本范围或多或少与我的目标投影区域匹配。但是还有另一种方法可以设置跨操作系统相同的大小吗?只是想确保我没有在这里遗漏任何东西。

I have a fixed strip I'm drawing, 50 pixels in height and as wide as my application main window.

I'd like to place text on that strip.

My problem is that even with the same font and size (arial 15 for example), the font will have a different height under OSX and Windows.

Is there a way to make this more predictable? I know I can use the QFont measuring mechanism until the extent of the text I need will match my target projection area, more or less. but is there another way to set size that'll be identical across operating systems? Just want to make sure I'm not missing something here.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜味超标? 2024-12-30 09:11:44

You can specify font heights in pixels using QFont::setPixelSize(). It's particularly handy when drawing text over fixed sized bitmaps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文