Written with QT ProgramAnd has written a Chinese language file (. (QM file), released to a system without QT installed, but found that only the Chinese in the Fixed Interface text can be normally displayed, while saving Chinese characters such as TXT and XML files during the running of the program turns into a strange encoding, And it turns into "? ".
After studying the QT documents, I finally learned the reason because the corresponding textcodec is used in the QT System for Unicode to local encoding (gb2312, the textcodec is not statically compiled into several library files of QT, but after compiling the QT System, it appears in the/QT/plugins/codecs directory as plugin. For example, the name of the codec library in simplified Chinese is qcncodecs4.dll, when I released the QT program, I only installed several main QT files (qtcore4.dll, qtgui4.dll), which caused the lack of Chinese codec on the system.
The solution is simple. There are multiple methods:
1) install the above Chinese encoding library file to the codecs directory under the executable program directory. When the program starts, the initialization process in qtcore will automatically find the Directory and load it To the memory.
2) When the QT program is startedCodeSpecify the library search path of QT.
3) Compile the QT. config file, put it in the directory of the executable file, and define the path of codecs.
4) for Qt compiled with static, write this macro command in the main program file: q_import_plugin (qcncodecs) and add the corresponding lib file to the link.
I will not talk about the specific content, see the QT documentation: DOC/html/plugins-howto.html
In addition, the QT image decoding system is also provided by plugin. If you forget to copy a decoding library such as JPEG and GIF, the program will only display BMP and PNG images.