Qte4 supports Chinese Fonts
Qt version: qte-4.6.2 Development Board: fl2440 Compiler: arm-unknown-linux-gnueabi-gcc-4.4.6 do not know the Chinese font QT interface, the font is displayed as a square or no content. Next we will solve this problem. 1. Download The wenquanyi font suffixed with qpf and copy wenquanyi_120_50.qpf and wenquanyi_120_70.qpf to $ qtdir/lib/fonts in the file system. Note: 120 is the 12-digit font, and 70 is bold compared with 50. Select the font number based on the LCD size of the Development Board. The size of the downloaded font is 12, 13, 15, or 16. 2. This step is related to programming. This is my example:
- # Include "mainwindow. H"
- # Include <qtextcodec>
- Int main (INT argc, char
* Argv [])
- {
- Qapplication app (argc, argv );
- Qtextcodec: setcodecforlocale (qtextcodec: codecforname ("UTF-8 "));
- Qtextcodec: setcodecfortr (qtextcodec: codecforname ("UTF-8 "));
// Supports tr Chinese
- Qtextcodec: setcodecforcstrings (qtextcodec: codecforname ("UTF-8 "));
// Supports display of Chinese file names
- Qfont font;
- Font. setpointsize (12 );
// Font size of 12
- Font. setfamily ("wenquanyi "));
- Font. setbold (false );
- App. setfont (font );
- Mainwindow window;
- Window. Show ();
- Bool OK = app.exe C ();
- ////////......
- Return OK;
- }
The key is the # include <qtextcodec> header file.
In this way, the program can support Chinese characters. For TTF fonts, you can use the makeqpf program of QT to convert them into qpf fonts.