Notes When publishing the Chinese QT Program

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.