zoukankan      html  css  js  c++  java
  • 两种解决Qt5显示中文乱码的方法(使用QStringLiteral和#pragma execution_character_set("utf-8")两种方法)

    升级到Qt5.X之后,原先解决的Qt显示中文乱码的方法突然不适用了,找了很多方式来解决这个问题
    第一种:
    在公司代码里看到的方法,先将对应的cpp文件用windows自带的记事本打开,另存为UTF-8格式,然后在代码中,遇到中文字符,使用QStringLiteral("中文")进行修饰

    这种方式每次新建一个class就要切出去用记事本编辑一下实在麻烦,而且每个中文字符串都要用QStringLiteral来修饰,实在麻烦
    后来有找到了个方法
    第二种:
    在头文件申明中加上
    #pragma execution_character_set("utf-8")
    一切OK了

    http://blog.csdn.net/shihoongbo/article/details/47677159

    http://woboq.com/blog/qstringliteral.html

  • 相关阅读:
    Hashmap实现原理
    策略模式
    Google Drive ubuntu
    numix Docky
    Google Drive 和 Dropbox 同步同一个文件夹目录
    sublime text 2
    matlab cell
    liteide
    taglist and nerdtree
    codeblocks
  • 原文地址:https://www.cnblogs.com/findumars/p/5083304.html
Copyright © 2011-2022 走看看