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

浪尽此生 提交于 2020-01-15 01:46:27

问题


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.


回答1:


qt framework translation files have to be added in the project translations folder together with qt_xx.qm, the correspondent qm dependency files have to be added.

qt_xx.qm contains only the name of those files - there is another answer explaining this here: Translations of QMessageBox not work in Qt5.3




回答2:


Just try this:

QTranslator translator;   
if(translator.load("E:/Qt/Linguist/translation_fa.qm"))
    qDebug()<<"successfully load qm file.";
else
    qDebug()<<"problem in load qm file.";


来源:https://stackoverflow.com/questions/46074603/how-can-i-include-c-qt-5-9-1-msvc2015-translations-qm-files-qt-framework-qm-f

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!