`
忧里修斯
  • 浏览: 426801 次
  • 性别: Icon_minigender_1
社区版块
存档分类
最新评论

QT中文乱码问题

阅读更多
#include <QtGui/QApplication>
#include <QPushButton>
#include <QTextCodec>

#include "mainwindow.h"

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    //设置编码为UTF-8,与文件编码保持一致
    QTextCodec *codec = QTextCodec::codecForName("UTF-8");
    QTextCodec::setCodecForLocale(codec);
    QTextCodec::setCodecForCStrings(codec);
    QTextCodec::setCodecForTr(codec);
//    MainWindow w;
//    w.show();
    QPushButton button("确定");
    button.show();
    return a.exec();
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics