How to slove the problem of garbage characters of Chinese and errors of images in QT

Source: Internet
Author: User

Sometimes it is miserable to find thatRelease VersionOf your software hasGarbage charactersAndErrors in Images.

Here isGood SolutionWhich has been tested to be OK.

1. InMain ()Function of your program, add thisAt the very beginning:

 
Qapplication: addlibrarypath ("./plugins ");

If it were not added at the very beginning of the program, the following program wocouldNotBe able to find the Plugins needed.

2.Create a new folderIn the release folder named"Plugins"Which will be used to hold the plugins that we need.

3. Go to the directory where your QT is installed. FindPlugins folder.

Mine is "D: \ qtsdk \ Desktop \ QT \ 4.7.4 \ mingw \ plugins"

4. Now you can see several folders: accessible, bearer, codecs, designer, graphicssystems ,...

5.CopyThe folderCodecsAndImageformatsTo the folder that we created before.

We have to copy the folder with all files.

If we just copies all the files but the folder that hold it, it will not work.

6.Set fontsIn the Code:

 
Qtextcodec * codec = qtextcodec: codecforname ("gb2312"); qtextcodec: codec (codec); qtextcodec: setcodecfortr (codec );

7. Now you can use Chinese and imagines with no trouble!

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.