国际化不能显示中文
绫波 2014-01-02 11:56:47 Qt5.1.1版本
建立一个简单的对话框,有个label,对话框开启时初始化文字
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
ui->label->setText(tr("--helloworld--!"));
}
要翻译tr("--helloworld--!")。
建立ts文件,转换为qm文件。main为
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QTranslator qtTranslator;
qDebug()<<QCoreApplication::applicationDirPath();
qDebug()<<qtTranslator.load("helloworld.qm");
qDebug()<<a.installTranslator(&qtTranslator);
Dialog w;
w.show();
return a.exec();
}
qDebug显示load和installTranslator为true,但是对话框中还是"--helloworld--!",不是翻译过的中文,我漏了什么吗?