QT中中文亂碼的解決

QT中中文亂碼的解決:shell

#include <QtGui/QApplication>
#include <QTextCodec>
#include "mainwindow.h"
 
int main(int argc, char *argv[])
{
 
    QApplication a(argc, argv);
    // 如下部分解決中文亂碼
    QTextCodec::setCodecForTr(QTextCodec::codecForName("GB2312"));
    QTextCodec::setCodecForLocale(QTextCodec::codecForName("GB2312"));
    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("GB2312"));
    // 以上部分解決中文亂碼
    MainWindow w;
 
    w.show();
 
    return a.exec();
}
相關文章
相關標籤/搜索