Problem summary cannot be used in the QT translation file qtranslator (original)

Source: Internet
Author: User

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>

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.