The use of QT internationalization Qtranslator __QT

Source: Internet
Author: User
QT Internationalization of the use of Qtranslator general use of QT design software, more use of the default English (including menus, buttons, dialog boxes, etc.) display, and then use the international functional class according to specific occasions, the same software to achieve the functions of different languages. Class Qtranslator is a class that implements internationalization and is easy to use. A simple and outrageous example:
    Qapplication A (argc, argv);

    Qtranslator *translator = new Qtranslator;
    Translator->load ("./testhello.qm");
    A.installtranslator (translator);
Of course, a software generally support a variety of languages, and hope that this set of language in the next landing is still the language of the setting, this will require a long-term maintenance of software settings information, such as the registry. An example of multiple languages:
    Qapplication app (argc, argv);

    Qsettings settings;
    QString language = Settings.value ("language"). toString ();
    
    Qtranslator Qttranslator;
    QString translationfile = ":/translations/qt_" + language + ". QM";
    Qttranslator.load (translationfile);
    App.installtranslator (&qttranslator);

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.