Qt应用开发(1)——中文字体库

本文介绍了如何在Linux环境下配置字体库以支持汉字显示,包括字体库路径和配置文件`/etc/fonts/fonts.conf`的设置。同时,针对Qt5.6和Qt4.8,提供了显示汉字的代码示例。另外,文章还讨论了Qt工程文件时间戳异常的问题,当系统时间不准确导致文件时间戳在未来时,会引发编译警告。解决方法是将系统时间调整到当前时间。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

字体库:
https://www.fonts.net.cn/fonts-zh/tag-wenquanyi-1.html
参考链接:
https://blog.csdn.net/kozazyh/article/details/79365706

字体库的路径及配置文件

/usr/share/fonts
/usr/local/share/fonts
/etc/fonts/fonts.conf

<!-- Font directory list -->
        <dir>/usr/share/fonts</dir>
        <dir>/usr/local/share/fonts</dir>
        <dir prefix="xdg">fonts</dir>
        <!-- the following element will be removed in the future -->
        <dir>~/.fonts</dir>

qt5.6显示汉字

http://bbs.witech.com.cn/article-253-1.html
ui->textEdit->setText(tr("中文"));

qt4.8显示汉字

tItem = new QTableWidgetItem(QString::fromLocal8Bit("中文"));

Qt工程文件时间戳问题

问题现象:

forlinx@forlinx:~/test$ make clean
make: Warning: File '/usr/lib/aarch64-linux-gnu/qt5/mkspecs/qconfig.pri' has modification time 34787072 s in the future
/usr/lib/qt5/bin/qmake -o Makefile fonts.pro
make: Warning: File '/usr/lib/aarch64-linux-gnu/qt5/mkspecs/qconfig.pri' has modification time 34787072 s in the future
/usr/lib/qt5/bin/qmake -o Makefile fonts.pro
make: Warning: File '/usr/lib/aarch64-linux-gnu/qt5/mkspecs/qconfig.pri' has modification time 34787071 s in the future
/usr/lib/qt5/bin/qmake -o Makefile fonts.pro
make: Warning: File '/usr/lib/aarch64-linux-gnu/qt5/mkspecs/qconfig.pri' has modification time 34787071 s in the future
/usr/lib/qt5/bin/qmake -o Makefile fonts.pro

问题原因:
文件最后修改的时间比当前系统的时间要晚。部分系统启动时没有联网,导致系统时间为设置的默认时间,比如1970.1.1。这样就会导致自己导入的工程文件比当前的系统时间还要晚,编译的时候就会报这个问题。
修复方法:修改当前的系统时间,设置为当前时间即可。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值