I’m using Qt-Embedded 4.7.3 and trying to show Chinese characters in the widgets.
I’ve built a x86 version of Qt-embedded so that I can test my application using qvfb. But I can not show chinese due to some unknown reason. Here is a test program I use:
#include <QApplication>
#include <QLabel>
#include <QTextCodec>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
QLabel* label = new QLabel("Chinese中文");
label->show();
return app.exec();
}
I have ‘WenQuanYiMicroHeiLight.ttf’ chinese font installed under lib/fonts. The Chinese characters are encoded in UTF-8, so according to the Qt Documment, this should allow me to display chinese in the widget. But when I run the application in QVFB, it’s didn’t show chinese.
Any ideas?
EDIT:
Later I found out it’s actually caused by the system(not really sure though). I switched to Debian and the Chinese are showing again. It might be related to package dependency problems on my old system (ArchLinux but holding gnome2 packages…)
Thanks for the answers.
I don’t know what the problem is, but it’s usually better to not include any non-ASCII characters in the code files, but write the code entirely in English and use Qt’s internationalization concept (tr, QTranslator, linguist) to translate the Gui.