In Qlinguist, I translated ui and some corresponding warning messages, generated qm file, and loaded it, but in the result it only can translate the ui, but not those warning messages. My code is like this:

void MainWindow::translate()
{
     QTranslator translator;
     translator.load ( "Test.qm", "D:\\" );
     qApp->installTranslator ( &translator );
     retranslateUi ( this );
}

MainWindow::MainWindow ( QWidget *parent ) : QMainWindow ( parent )
{
    setupUi(this);
    translate();
    ...
}

One of my warning messages is in this form:

QMessageBox::warning( this, QMessageBox::tr("ERROR"), QMessageBox::tr("Invalid IP adress") );

This string can be load by lupdate, and I translated it in its qm file, but still cannot see its translation after running. Here I asked about it, but I have to open this new question in order to solve it with someone's help. Can someone help me on this? Thank you in advance.

有帮助吗?

解决方案

Creating the translator on the stack, it will be deleted right away at the end of translate(). Try to create it on the heap instead so it lives on.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top