First, go to the relevant content in www.qtcn.org:
Certificate ------------------------------------------------------------------------------------------------------------------------------------------------
Why are Chinese characters in my qtembedded program displayed as squares?
There are two possible reasons:
First, the QTE library is not compiled into the support for Chinese textcodec, solution: Modify the qconfig-qpe.h, remove the macros related to codec, re-configure and make
Second, the font selected in the program is not a Chinese font (the default font is Helvetica and there is no Chinese). You must specify a Chinese font in the program, for example, QTE's built-in uniont (which is generally regarded as defective). In qt4, the Unicode font of wenquanyi is added, which can be found in the source code package. It is pretty and recommended.
Certificate ------------------------------------------------------------------------------------------------------------------------------------------------
Next, let's talk about how I did it:
(1) When configure is used, first take a look at the description with-h, and find that the default is full installation, there will be no codec problems, then the displayed square is no Chinese font, I tried it with uniont and found it was okay.
(2) download the qtopia-core-opensource-src-4.2.0, The qtopia-core-opensource-src-4.2.0/lib/fonts below all copy overwrite qt-embedded-free-3.3.5/lib/fonts under the content, and then use the wenquanyi font, found that the effect is quite good.
(3) My test procedure is as follows:
# Include <qapplication. h>
# Include <qpushbutton. h>
# Include <qtextcodec. h>
# Include <qfont. h>
Int main (INT argc, char ** argv)
{
Qapplication app (argc, argv );
Qtextcodec * codec = qtextcodec: codecforname ("GBK ");
App. setdefacodecodec (codec );
App. setfont (qfont ("wenquanyi", 10 ));
Qpushbutton quit (qobject: TR ("let the world know we are all Chinese/R/n five thousand years of wind and rain"), 0 );
Quit. Resize (100,100 );
Qobject: connect (& quit, signal (clicked (), & A, slot (quit ()));
A. setmainwidget (& quit );
Quit. Show ();
Return a.exe C ();
}
(4) I also read how to install TTF fonts under qtopia on www.qtcn.org.
Installation steps:
1. Copy simhei. TTF to/usr/local/trolltech/QtopiaCore-4.1.0/lib/fonts.
2. Modify the fontdir file in the preceding directory. This is a text file. After opening it, add the following line to the end of the file.
Simhei. TTF ft n 500 u
But I want to use FreeType, the font engine plug-in, which is already available in my system, and configure carries this parameter by default. I will try it according to the above practice, the font is ugly, and the font without wenquanyi looks nice. Why is it depressing to know whether the FreeType plug-in works?