嵌入式系统中未显示的中文字符(yocto,Qt 5.5.1) - 为什么Qt不使用系统字体?
Chinese characters not shown in embedded system (yocto, Qt 5.5.1) - why Qt doesn't use system fonts?
虽然以下代码在桌面linux和Windows上都可以使用,但汉字在嵌入式Linux上显示出汉字(Yocto jethrow,qt 5.5.5.1,x11上的qt)。QT似乎使用自己的字体,而不是该系统上的系统字体。注意:在" Hello World"之后,应该有中文" Nihao"。
main()的C 内容:
QApplication a( argc, argv );
QString s = QString::fromUtf8("Hello world u611b!");
QPushButton hello;
// eventually set font here, see below
hello.setText(s);
hello.resize( 200, 30 );
hello.show();
return a.exec();
在另一个使用QT 4的嵌入式系统上,仅安装合适的字体就足够了。该字体也可以在此处正确安装,并由FC列表识别。
如果我修改上面的代码并直接设置字体,则可以按预期工作:
// insert font here:
int id = QFontDatabase::addApplicationFont("/usr/share/fonts/wqy/wqy-microhei.ttc");
QString family = QFontDatabase::applicationFontFamilies(id).at(0);
QFont font(family);
hello.setFont(font);
// end modification
hello.setText(s);
如果我制作了一个简单的QML脚本,我还必须设置字体。但是,如果我使用Web引擎浏览器窗口小部件,它可以显示中文字符。
命令" fc-list"(解放,wqy-microhei)显示的字体和QT函数" qt.fontfamilies()"(bitstream,luxi,dejavu,dejavu,curier,Cursor,Cursor,Cursor,utopia)是不同的。
是否可以在不重新编译QT或应用程序的情况下更改QT配置,以使WQY-Microhei用于汉字?
尽管此嵌入式系统在x11上使用QT,但该解决方案是将字体复制到/usr/lib/fonts中,如下所述:
https://doc.qt.io/qt-5/qt-embedded-fonts.html
似乎在此系统上QT/X11集成尚未完成。用作基础的Yocto Meta-QT5层默认情况下未使用X11。它被切换到X11,以便使用X11VNC。
相关文章:
- Qt/C++ 系统单元启动/停止时的信号
- 如何设置Qt应用程序以使用类Unix系统的实际环境变量?
- C++ / Qt:如何检测主机名或IP地址何时引用当前系统?
- 如何检测两个文件条目是否引用与Qt相同的物理文件系统?
- 适用于 macOS 的 Qt 5.9.1 的系统托盘应用程序
- 使用具有新信号槽语法的Qt插件系统在接口类中声明信号
- 强制系统 QT 库使用应用程序附带的 openssl 库
- 在QT资源系统中,前缀比文件系统路径的优势是什么?
- 如何在Qt中打开外部应用程序并将其最小化到系统托盘
- 如何正确使用qt的信号/插槽系统
- 嵌入式系统中未显示的中文字符(yocto,Qt 5.5.1) - 为什么Qt不使用系统字体?
- 通过QT中的信号和插槽系统传递变量
- 如何在没有窗口类的情况下编写QT系统托盘应用程序,并将其与另一个进程集成
- CMAKE QT翻译系统的适当工作流程
- 为嵌入式系统构建QT时错误
- Qt中一个类似事件系统的信号/槽,没有分叉-C++
- 如果堆分配的对象被销毁并且指针被重新分配,Qt的信号和插槽系统会工作吗?
- 在Qt C++中使用文件系统
- Qt 4.8.3 中的 Qt 资源系统错误
- 实施您自己的属性系统(类似QT)