zoukankan      html  css  js  c++  java
  • How to slove the problem of Garbage Characters of Chinese and Errors of Images in Qt

    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:

        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!

  • 相关阅读:
    get 方式获取ajax
    javascript 面试题目
    原生js 制作选项卡切换效果
    js 回到顶部效果
    php mysql
    浏览器高度 clientHeight 与scrollHeight offsetHeight
    js dom中删除子节点removeChild
    Javascript综合笔记
    Ka贪心大暴走
    Openjudge NOI题库 ch0111/t1794 集合加法
  • 原文地址:https://www.cnblogs.com/johnpher/p/2676768.html
Copyright © 2011-2022 走看看