即在 main.cpp文件中加入#include 的头文件包含。
再在下面的主函数里添加QTextCodec::setCodecForTr(QTextCodec::codecForLocale());
这样就可以使用tr(“中文”)
int main(intargc, char *argv[])
{
QApplication a(argc, argv);
QTextCodec::setCodecForTr( QTextCodec::codecForLocale());//中文显示设置
MainWindow w;
w.show();
return a.exec();
}