Qt:字体大小或更确切地说是高度
我正在绘制一个固定条带,高度为 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 QFont::setPixelSize()< 以像素为单位指定字体高度/a>.在固定大小的位图上绘制文本时,它特别方便。
You can specify font heights in pixels using QFont::setPixelSize(). It's particularly handy when drawing text over fixed sized bitmaps.