How to slove the problem of Garbage Characters of Chinese and Errors of Images in Qt
2012-09-08 16:27
686 查看
Sometimes it is miserable to find that the release version of your software has Garbage Characters and Errors in Images.
Here is a good solution which has been tested to be ok.
1. In the main() function of your program, add this at the very beginning:
If it were not added at the very beginning of the program, the following program would not be able to find the plugins needed.
2. Create a new folder in 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. Find the plugins 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. Copy the folder of codecs and imageformats to 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 fonts in the code:
7. Now you can use Chinese and Imagines with no trouble!
Here is a good solution which has been tested to be ok.
1. In the main() function of your program, add this at the very beginning:
QApplication::addLibraryPath("./plugins");
If it were not added at the very beginning of the program, the following program would not be able to find the plugins needed.
2. Create a new folder in 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. Find the plugins 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. Copy the folder of codecs and imageformats to 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 fonts in the code:
QTextCodec *codec = QTextCodec::codecForName("GB2312"); QTextCodec::setCodecForLocale(codec); QTextCodec::setCodecForCStrings(codec); QTextCodec::setCodecForTr(codec);
7. Now you can use Chinese and Imagines with no trouble!
相关文章推荐
- Qt How to get the width and height of a widget
- how to accepte the array of the checkbox in asp and in php
- How to change the language of oracle sqlplus from chinese to english in windows(如何将oracle sql plus中的中文变成英文版)
- How to say all the keyboard symbols in English and Chinese
- Weblogic Server in the Chinese show how to solve the problem hash
- How to resolve errors opening currentsettings.vssettings in the final release of VS 2008
- How to get and set the drawing order of layers in globe(获取并设置Globe图层的叠加次序:)
- How to collect TrustZone debug logs and check the meaning of error code in the logs
- How to hide my site and my document link in the right-top corner of sharepoint 2010
- How to invoke the method of managed bean and render view in JSF when we are outside the lifecycle of JSF
- [Yii Framework] How to embed the css and images in a module
- Dynamic linking is coming to iOS, tvOS, and watchOS ports of Qt in the 5.9 release
- GSR :the meaning of <load sharing elements> <refernce><refcount> in CEF and how to calculate them
- How to solve problem caused when the CRT library and MFC libraries are linked in the wrong order
- [Android 問題] How to Add a Button in ListView, and Make the Event of onClick and onItemClick Coexist?
- How to Get First and Last Day of a Week in SQL Server
- How to get the value of a form element : check box and radio button
- how to put the text on the left of a radio button in android
- How to install Android SDK and play with Android 2.0 in the emulator