Qt字体在不同的系统上具有不同的大小 [英] Qt fonts have different sizes on different systems

查看:520
本文介绍了Qt字体在不同的系统上具有不同的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Qt Designer创建ui文件时,发生以下问题:

Using Qt Designer for the creation of ui-files, the following problem occurred:

在不同的Linux系统上打开相同的ui文件会导致字体大小的不同显示.因此,当在另一系统上使用Qt Designer打开它们时,在一个系统上创建的ui文件可能具有太大的字体.这使文本在许多情况下不可读.窗口小部件的点大小"在两个系统上都相同,但是为了使其在两个系统上都可读,我必须在一个系统上的Qt Designer中手动减小点大小. 我该怎么做才能确保所有系统上字体的可读性?

Opening the same ui-file on a different Linux system results in different displaying of the font sizes. So, the ui-files created on one system may have too large fonts, when opening them with Qt Designer on another system. This makes text unreadable in many cases. The "point size" of the widgets is the same on both systems, but in order to make it readable on both, I have to manually decrease the point size in Qt Designer on one system currently. What can I do to assure the readablility of fonts on all systems?

使用的系统是SLES 10,SLES11,Debian.

Used systems are SLES 10, SLES11, Debian.

推荐答案

我遇到了类似的问题.在我们的情况下,它与本地Linux字体设置有关.而且由于无法强制世界上的所有计算机都使用相同的字体,因此我们在应用程序中覆盖了字体.

I have encountered a similar problem. In our case it had to do with the local Linux font settings. And since we couldn't force all computers in the world to use the same font we override the font in our application.

QFont _Font("Tahoma", 8);
QApplication::setFont(_Font);

您应该在创建主窗口之前执行此操作.

You should do this before your main window is created.

我所知道的唯一风险是,如果您选择的字体在计算机上没有安装,我相信它将恢复为默认设置.

The only risk I know of is, if by some chance the font you select is not installed on the computer, I believe it will go back to the default.

我希望能帮上忙.

这篇关于Qt字体在不同的系统上具有不同的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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