qt4 显示中文

    QTextCodec::setCodecForTr(QTextCodec::codecForLocale());
    QTextCodec::setCodecForTr(QTextCodec::codecForName("eucKR"));
If the literal quoted text in the program is not in the Latin-1 encoding, this function can be used to set the appropriate encoding.

#include <QtGui/QApplication>
#include "mainwindow.h"
#include<QTextCodec>//add
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QTextCodec::setCodecForTr(QTextCodec::codecForLocale());//add
    MainWindow w;
    w.show();
    return a.exec();
}



你可能感兴趣的:(qt4 显示中文)