3

How can I include C:\Qt\5.9.1\msvc2015\translations .qm files (Qt framework qm files) in final release, Visual Studio Qt project?

I am loading the files using:

    QTranslator* qtTranslator = new QTranslator();
bool ok = qtTranslator->load("qt_" + language, QLibraryInfo::location(QLibraryInfo::TranslationsPath));

in release and debug the translations work, but in the final build they don't and it is most probable that it's because they are not added.

I noticed that if i move them in my project they are not loaded.

4

2 回答 2

1

qt框架翻译文件必须与qt_xx.qm一起添加到项目翻译文件夹中,必须添加对应的qm依赖文件。

qt_xx.qm 仅包含这些文件的名称 - 这里有另一个答案解释这一点:QMessageBox 的翻译在 Qt5.3 中不起作用

于 2017-09-11T08:33:16.123 回答
0

试试这个:

QTranslator translator;   
if(translator.load("E:/Qt/Linguist/translation_fa.qm"))
    qDebug()<<"successfully load qm file.";
else
    qDebug()<<"problem in load qm file.";
于 2017-09-06T12:04:49.990 回答