所有qm和ts文件都准备好了,当我更改语言表单菜单时,主窗口已被翻译,但按摩盒没有....
我是否必须制作一个msgbox obj而不是将它们放在一行?
语言菜单
QTranslator lang_translator;
QCoreApplication::instance()->removeTranslator(&lang_translator);
switch(index)
{
case 0:
lang_translator.load(":/lang/en_us.qm");
QCoreApplication::instance()->installTranslator(&lang_translator);
ui->retranslateUi(this);
break;
case 1:
lang_translator.load(":/lang/ja_jp.qm");
QCoreApplication::instance()->installTranslator(&lang_translator);
ui->retranslateUi(this);
break;
default:
lang_translator.load(":/lang/en_us.qm");
QCoreApplication::instance()->installTranslator(&lang_translator);
ui->retranslateUi(this);
break;
}
消息框
QMessageBox::critical(this,str_title,tr("Failed"),QMessageBox::Ok);
=============================================== ===== EDITED
即使我尝试这个仍然失败
QString ffffff = tr("about_text"); //or next line
QString ffffff = QApplication::translate("MainWindow","about_text",Q_NULLPTR);
QMessageBox a;
a.setText(ffffff);
a.exec();
它只是无法获取翻译后的字符串,为什么........