在Qt中添加一个自定义字体 [英] Add a custom font in Qt

查看:1849
本文介绍了在Qt中添加一个自定义字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

怎么样?我们如何将它设置为文本编辑器(QPlainTextEdit,QTextEdit等)?

谢谢

解决方案

Qt使用您的窗口系统作为字体提供程序。您可以使用 QFontDatabase 类找到所有可用的字体。无论如何,可以使用 QFontDatabase为您的应用程序添加特定的自定义字体:: addApplicationFont (只有在fontconfig可用的情况下才可在X11下使用)或使用 FontLoader 组件在QML中。



对于QTextEdit,您可以使用这个,对于QPlainTextEdit,你可以尝试字体属性。


There's anyway to add a custom font (Such as Console Font) to Qt? How? And how do we set it to a Text Editor (QPlainTextEdit, QTextEdit, etc)?

Thanks

解决方案

Qt uses your window system as a font provider. You can find out all the fonts available by using the QFontDatabase class. Anyway, it is possible to add a specific custom font for your application to use using QFontDatabase::addApplicationFont from C++ (available under X11 only if fontconfig is available) or using the FontLoader component in QML.

For QTextEdit you can use this and for QPlainTextEdit you might try the font property.

这篇关于在Qt中添加一个自定义字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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