XI, global Qt's character set encoding to UTF-8, to solve the problem of Chinese garbled

Set () entry in the application's main function, as follows:

#include "mymainwindow.h"
#include <QApplication>
#include <QTextCodec>


int main(int argc, char *argv[])
{
    //增加全局支持 Uicode 识别支持,解决中文乱码问题
    QTextCodec *code = QTextCodec::codecForName("UTF-8");
    QTextCodec::setCodecForLocale(code);
    
    QApplication a(argc, argv);
    MyMainWindow w;
    w.show();

    return a.exec();
}
Published 444 original articles · won praise 113 · Views 400,000 +

Guess you like

Origin blog.csdn.net/panchang199266/article/details/104043023