Qt 汉字显示问题//QTextCodec::setCodecForTr(QTextCodec::codecForName("gb18030"));
2014-10-13 15:11
169 查看
Qt控件中含有汉字的话,需要对汉字编码进行转换,使用tr()函数对可见字符进行转化,在选择tr字符的时候使用//QTextCodec::setCodecForTr(QTextCodec::codecForName("gb18030"));
选用gb18030时候发现在别的机器上运行时候显示乱码,猜测是因为那台机器上没有gb18030字体,并且qt没能找到相近的字体,所以
显示乱码
后来改用QTextCodec::setCodecForTr(QTextCodec::codecForLocale());
这样就可以再那台机器上正常显示了.
选用gb18030时候发现在别的机器上运行时候显示乱码,猜测是因为那台机器上没有gb18030字体,并且qt没能找到相近的字体,所以
显示乱码
后来改用QTextCodec::setCodecForTr(QTextCodec::codecForLocale());
这样就可以再那台机器上正常显示了.
相关文章推荐
- Qt5 取消了QTextCodec::setCodecForTr()和QTextCodec::setCodecForCString()这两个函数。
- Qt5 取消了QTextCodec::setCodecForTr()和QTextCodec::setCodecForCString()这两个函数。
- target is null for setProperty(null, "username", [Ljava.lang.String;@c06258)问题
- QT 文本html显示格式的问题,如在QTextBrowser.setText用tr(),其中为html格式
- 使用百度地图2.9sdk Undefined symbols for architecture x86_64: "_NSBackgroundColorAttributeName", 问题解决方法
- QT 文本html显示格式的问题,如在QTextBrowser.setText用tr(),其中为html格式
- qt汉字显示的问题 && qt中不显示标题栏的方法
- WEB开发错误收集(二) ognl.OgnlException: target is null for setProperty(null, "name", [Ljava.lang.String;@f6
- qt 出现 error: 'setCodecForTr' is not a member of 'QTextCodec'等错误的请进..
- 终极解决XDebug的进度条会停在57%,显示"waiting for XDebug session"的问题
- QT编程中编译的时候出现c_jkdacx0.obj : error LNK2001: 无法解析的外部符号 "class QTextCodec * GlobalCodec" ?
- ognl.OgnlException: target is null for setProperty(null, "name", [Ljava.lang.String;@f6
- 解决jpivot导出PDF汉字显示"#"问题
- target is null for setProperty(null, "name", [Ljava.lang.String;@ffc6ae)
- eclipese连接MySQL出错“Class.forName("com.mysql.jdbc.Driver")”问题解决
- 对于Name属性没有get/set方法引起的:target is null for setProperty(null, "x", [Ljava.lang.String;@1a48515)异常
- how to set proxy for "darcs get"
- ubuntu中gedit,vim中文以及"^M"显示问题
- `QtValidLicenseForCoreModule' does not name a type 错误的解决
- Struts2学习之package name="struts2"对应谁--There is no Action mapped for namespace / and action name 异常