嵌入式linux下,QT5.6.3中文显示问题(最完整的整理)

2019-07-12 15:50发布

QT4.X跟QT5.6设置中文显示的步骤不一样,下面是qt5.6.3的profile和main.cpp文件。 1. 加入这段之后,再把DroidSansFallbackFull.ttf或者DroidSansFallback.ttf放到特定目录下边,然后设置一下环境变量(放到/etc/profile最下面): export QTEDIR=/mnt/qt5env_arage
export LD_LIBRARY_PATH=$QTEDIR/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$QTEDIR/libx:$LD_LIBRARY_PATH
export QT_QPA_FONTDIR=$QTEDIR/lib/fonts
export QT_QPA_PLATFORM_PLUGIN_PATH=$QTEDIR/plugins
export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0:size=480x272:mmSize=480x272:offset=0x0:tty=/dev/tty1
export LD_PRELOAD=/mnt/qt5env_arage/libx/preloadable_libiconv.so     2.main.cpp文件 #include "widget.h"
#include
#include int main(int argc, char *argv[])
{
    QApplication a(argc, argv);       Widget w; //这一关键部分,是从网上抄的     int id = QFontDatabase::addApplicationFont("/mnt/qt5env_arage/lib/fonts/DroidSansFallbackFull.ttf");
    QString msyh = QFontDatabase::applicationFontFamilies (id).at(0);
    QFont font(msyh,10);
    font.setPointSize(20);
    w.setFont(font);     w.show();     return a.exec();
} 3.DroidSansFallbackFull.ttf文件下载地址: https://download.csdn.net/download/zzqnsg/10885988