简体   繁体   English

Qt字体在不同系统上具有不同的大小

[英]Qt fonts have different sizes on different systems

Using Qt Designer for the creation of ui-files, the following problem occurred: 使用Qt Designer创建ui文件,出现以下问题:

Opening the same ui-file on a different Linux system results in different displaying of the font sizes. 在不同的Linux系统上打开相同的ui文件会导致不同的字体大小显示。 So, the ui-files created on one system may have too large fonts, when opening them with Qt Designer on another system. 因此,在一个系统上创建的ui文件在使用另一个系统上的Qt Designer打开它们时可能会有太大的字体。 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. 小部件的“点大小”在两个系统上都是相同的,但为了使它们都可读,我必须在当前的一个系统上手动减小Qt Designer中的点大小。 What can I do to assure the readablility of fonts on all systems? 我该怎么做才能确保所有系统上字体的可读性?

Used systems are SLES 10, SLES11, Debian. 使用的系统是SLES 10,SLES11,Debian。

I have encountered a similar problem. 我遇到过类似的问题。 In our case it had to do with the local Linux font settings. 在我们的例子中,它与本地Linux字体设置有关。 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. 我所知道的唯一风险是,如果你选择的字体有可能没有安装在计算机上,我相信它会回到默认状态。

I hope that helps. 我希望有所帮助。

Use void QFont::setPixelSize(int pixelSize) instead of ::setPointSize. 使用void QFont :: setPixelSize(int pixelSize)而不是:: setPointSize。

Using this function makes the font device dependent. 使用此功能可使字体设备相关。 Use setPointSize() or setPointSizeF() to set the size of the font in a device independent manner. 使用setPointSize()或setPointSizeF()以与设备无关的方式设置字体大小。

I migrated from Windows8 to Windows8, and the font size dont match. 我从Windows8迁移到Windows8,字体大小不匹配。 I tried to force it via the main.cpp using 我尝试通过main.cpp强制使用它

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

It did change some items, but some didnt. 它确实改变了一些项目,但有些没有。 I tried to check the Class configuration but didnt find any think that will help. 我试图检查类配置,但没有发现任何认为会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM