I used a translation file in my project today and found that it did not work. I searched for it repeatedly and found that I used a macro to define the namespace and generate it. TS files are generated because no namespace is added. when the Qm file is actually used, the corresponding statement cannot be found.
If you change the macro-defined namespace to a normal character, no such problem occurs.
I used namespace myproject {to use # define usns namespace myproject {to define a macro and directly use the Macro. Therefore, you cannot convert the macro into a file.
To sum up the several notes for translation:
1. Basic usage
Qtextcodec * textcodec = qtextcodec: codecforname ("System"); Qtextcodec: setcodecforlocale (textcodec); qtranslator translator; translator. Load (":/Testtranslate/testtranslate_zh.qm"); A. installtranslator (& Translator );
2. Before creating the app in the window, call
3. If the class is in a namespace, the name of the generated. Ts file will be added to the namespace name. If the namespace is not added, an exception will occur during the installation of the translation file. As follows:
<Name> tttt: testtranslate </Name>