一,用QStringLiteral
QMessageBox::about(this,"clicked",QStringLiteral("1按钮被单击1"));
二、现在Qt5放弃了上面的方法,网上都建议用:
首先将VC里的源代码都保存(VS菜单”文件->高级保存选项")成UTF-8格式
1
2
3
|
#if _MSC_VER >= 1600
#pragma execution_character_set(
"utf-8"
)
#endif
|
以下方法,我实了不行。
1、以前qt4+VS2008是通过下面方法解决,后面两个函数QT已经取消了。
1
2
3
4
|
QTextCodec *codec = QTextCodec::codecForName(
"gbk"
);
QTextCodec::setCodecForLocale(codec);
QTextCodec::setCodecForCStrings(codec);
QTextCodec::setCodecForTr(codec);
|