设置Qt编码为utf-8

  1 #include "mainwindow.h"
  2 #include <QApplication>
  3 #include <QTextCodec>
  4 
  5 int main(int argc, char *argv[])
  6 {
  7     QApplication app(argc, argv);
  8     QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));  //设置为utf8   
  9     MainWindow w;
 10     w.show();
 11     
 12     return app.exec();
 13 }
~        

你可能感兴趣的:(设置Qt编码为utf-8)