Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How do I change the language without having to restart the application?

How do I change the language without having to restart the application?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 241 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Blackzero
    wrote on last edited by
    #1

    How does the transtalor work when pressing the transalte menubar without having to restart the application?

    void MainWindow::on_actionEN_triggered()
    {
        QTranslator translator;
        if (translator.load(":/lang/lang_en.qm")) {
            qApp->removeTranslator(&translator); 
            qApp->installTranslator(&translator);
        }
        else {
            qDebug() << "Failed to load translation file";
        }
    }
    
    
    jsulmJ 1 Reply Last reply
    0
    • B Blackzero

      How does the transtalor work when pressing the transalte menubar without having to restart the application?

      void MainWindow::on_actionEN_triggered()
      {
          QTranslator translator;
          if (translator.load(":/lang/lang_en.qm")) {
              qApp->removeTranslator(&translator); 
              qApp->installTranslator(&translator);
          }
          else {
              qDebug() << "Failed to load translation file";
          }
      }
      
      
      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Blackzero said in How do I change the language without having to restart the application?:

      QTranslator translator;

      Think about the lifetime of the translator object...

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      4

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved