Important: Please read the Qt Code of Conduct -

QTranslator do not work at all

  • os : windows 10 64 bits
    Qt : 5.9.4, vc2017 64bits

    1. Wrap the text by tr or QObject::tr.
    2. Generate the ts file,
    3. Translate almost every words of the ts file(some of them are left empty).
    4. Run lrelease to generate qm file
    5. Load the qm file as following
    QTranslator custom_translator_;
    if(custom_translator_.load("english_to_turkish.qm", a.applicationDirPath())){
        qDebug()<<__func__<<"can load english to turkish";
            qDebug()<<__func__<<"can install translator";
            qDebug()<<__func__<<"cannot install translator";
        qDebug()<<__func__<<"cannot load english to turkish";

    The return values tell me qm file can be loaded and installed, but none of the text are translated to Turkish, every words remain as English. Any possible wrong I commit? Thanks

  • Moderators

    Do you install your translations before instantiating the GUI or after?

  • @sierdzio Yes.

    I find out the issue, the problem is life time, I put the QTranslator in a class, and that class is enclosed by {}, that is why the text did not translated, a stupid bug.

Log in to reply