QFontDatabase: Cannot find font directory /usr/local/Qt-5.11.3/lib/fonts
Note that Qt no longer ships fonts. Deploy some (from https://dejavu-fonts.github.io/ for example) or switch to fontconfig.
解决
下载 dejavu-fonts-ttf-2.37.tar.bz2
创建目录并拷贝所有ttf文件 /usr/local/Qt-5.11.3/lib/fonts
重启qtcreator.sh 重新编译项目
问题背景
centos7-aarch64 使用gcc7 编译qt5.11.3和 qtcreator
运行项目,widgets组件可以显示,但是没有字体,控制台报错
原因分析
检查系统默认字体 yum install fontconfig
查看以安装字体 fc-list && fc-list :lang=zh
/usr/share/fonts
/usr/share/X11/fonts
#include <QFontDatabse>
QFontDatabase database;
foreach (const QString &str, database.families()) {
qDebug() << str;
}
foreach (const QString &str, database.families(QFontDatabase::SimplifiedChinese)) {
qDebug() << str;
}
参考
银河麒麟aarchQt5.12.0 QtFontDatabase: Cannot find font directory
标签:Qt,fonts,centos7,字体,usr,font,缺失 From: https://www.cnblogs.com/cstc/p/18354344