I have a QT application and I need to change language at runtime. I am using QTranslator and .qm files. The language is loaded properly but my widgets don't show the text.

Y have 'MyClass..cpp' (inherits QMainWindow):

Qt Code:
  1. MyClass::MyClass()
  2. {
  3. ...
  4. selectLanguage("en");
  5.  
  6. m_pLabel = new QLabel(tr("User"));
  7. m_pLabel->show();
  8.  
  9. ...
  10. }
  11.  
  12. void MyClass::selectLanguage(QString language) {
  13.  
  14. QString sTranslationFile = QString("texts_%1").arg(language);
  15.  
  16. QTranslator translator;
  17. //translator.load(":/translations/" + sTranslationFile);
  18. translator.load(sTranslationFile, ":/translations/");
  19.  
  20. if (qApp->installTranslator(&translator))
  21. qDebug() << "Ok";
  22. }
  23.  
  24. void MyClass::changeEvent(QEvent *pEvent)
  25. {
  26. if(pEvent)
  27. {
  28. switch(pEvent->type())
  29. {
  30. case QEvent::LanguageChange:
  31. retranslate();
  32. break;
  33. }
  34. }
  35.  
  36. QMainWindow::changeEvent(pEvent);
  37. }
  38.  
  39. void MyClass::retranslate()
  40. {
  41. qDebug() << "retranslate";
  42.  
  43. if (m_pLabel)
  44. m_pLabel->setText(tr("User"));
  45. }
To copy to clipboard, switch view to plain text mode 

In 'myProject.pro':

Qt Code:
  1. ...
  2. QMAKE_POST_LINK = lrelease.exe myProject.pro
  3. ...
  4. RESOURCES += \
  5. resources/resources.qrc
  6.  
  7. TRANSLATIONS += resources/translations/texts_en.ts \
  8. resources/translations/texts_es.ts
  9. ...
  10. DISTFILES += \
  11. ...
  12. resources/translations/texts_en.qm \
  13. resources/translations/texts_es.qm
  14. In 'resources.qrc':
  15.  
  16. ...
  17. translations/texts_en.qm
  18. translations/texts_es.qm
To copy to clipboard, switch view to plain text mode 

In 'texts_en.ts':

Qt Code:
  1. <!DOCTYPE TS><TS>
  2. <context>
  3. <name>MyClass</name>
  4. <message>
  5. <source>User</source>
  6. <translation>UserEn</translation>
  7. </message>
  8. <message>
  9. <source>Group</source>
  10. <translation>GroupEn</translation>
  11. </message>
  12. </context>
  13. </TS>
To copy to clipboard, switch view to plain text mode 

Language is loaded ("Ok" appears) and "retranslate" is called, but the label does NOT show "UserEn", but "User"...

I call 'selectLanguage("es")' after a while, but the same...

I hope somebody could help me.

Thanks in advance,

Diego