Important: Please read the Qt Code of Conduct -


  • Hi guys, a doubt: I'm reading about the qtranslator class and seems to me that i can't switch the language in the execution time, only when the app is not loaded, this is correct?
    On this case when the user switch the language i will need killl and restart my app, correct?

  • Lifetime Qt Champion


    No, you can do it at run time. See the documentation here

  • @SGaist I'm confused.
    Inside my app the user select the language that hes prefer to use. On the trigger event i need translate my Ui's. But inside my class i dont see how to do it. Because the first translate on my app occurs on main.cpp, and the event that im talking stays inside on my brprint.cpp file. How to do it?
    I'm trying this, but nothing happens.

    void BrPrint3D::on_actionPortuguese_triggered()
        QTranslator trans;

  • Have you looked at the example I gave a link to?

    To change the language dynamically you to do 2 things:

    1. install translator .
      From the code i referred to:

    void switchTranslator(QTranslator& translator, const QString& filename)
    // remove the old translator

    // load the new translator

    1. Update controls for every widget which needs a translation.
      In the referred code this is done by calling ui.retranslateUi()

    void MainWindow::changeEvent(QEvent* event)
    if(0 != event) {
    switch(event->type()) {
    // this event is send if a translator is loaded
    case QEvent::LanguageChange:


  • This post is deleted!

  • @alex_malyu How i can access my qApp on main.cpp starting from my class A? thats my doubt. Because the action to change language is tiggered from my class A. I'm try pass qApp by reference to my class A but the qt dont accept.

  • #include <QCoreApplication>



    Like a global pointer: QApplication* qApp

Log in to reply