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. Linguist: how to dynamically switch language of all UI?
Forum Updated to NodeBB v4.3 + New Features

Linguist: how to dynamically switch language of all UI?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 1.1k Views 2 Watching
  • 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.
  • brucezcgB Offline
    brucezcgB Offline
    brucezcg
    wrote on last edited by aha_1980
    #1
    Question 1) What is the simple way to do this?
    Question 2) For example: 
    class ZWgtItem::public QWidget{
    private:
     QLabel * mMainTitle,*mSubTitle;
    }
    
    I had many ZWgtItem widget items, so how to translate when change language?
    
    Thanks.
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      It's described in the Internationalisation chapter in Qt's documentation.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      brucezcgB 1 Reply Last reply
      2
      • SGaistS SGaist

        Hi,

        It's described in the Internationalisation chapter in Qt's documentation.

        brucezcgB Offline
        brucezcgB Offline
        brucezcg
        wrote on last edited by
        #3

        @SGaist Thanks, but this is not suitable for me.

        I had so many ZWgtItem widgets dynamically new from source code.
        So it would be awful to do translate like this:

        changeEvent(){
        ******
        QVector<ZWgtItem*> wgtlist;
        //Language change
        for(int i=0; i<wgtlist.length(); i++){
        if(i==0)
        wgtlist[i].setMainTitle(tr("xxxxx"));
        else if(i==1)
        wgtlist[i].setMainTitle(tr("yyyyy"));
        else if(i==2)
        wgtlist[i].setMainTitle(tr("zzzzz"));
        .................

            }
        

        }

        mrjjM 1 Reply Last reply
        0
        • brucezcgB brucezcg

          @SGaist Thanks, but this is not suitable for me.

          I had so many ZWgtItem widgets dynamically new from source code.
          So it would be awful to do translate like this:

          changeEvent(){
          ******
          QVector<ZWgtItem*> wgtlist;
          //Language change
          for(int i=0; i<wgtlist.length(); i++){
          if(i==0)
          wgtlist[i].setMainTitle(tr("xxxxx"));
          else if(i==1)
          wgtlist[i].setMainTitle(tr("yyyyy"));
          else if(i==2)
          wgtlist[i].setMainTitle(tr("zzzzz"));
          .................

              }
          

          }

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #4

          @brucezcg
          Hi
          That IS the only way of doing dynamic language changing. ( reset the text again so TR macro can lookup new text)
          Alternatively, you can restart the application.

          brucezcgB 1 Reply Last reply
          1
          • mrjjM mrjj

            @brucezcg
            Hi
            That IS the only way of doing dynamic language changing. ( reset the text again so TR macro can lookup new text)
            Alternatively, you can restart the application.

            brucezcgB Offline
            brucezcgB Offline
            brucezcg
            wrote on last edited by
            #5

            @mrjj I wanna cry.
            But Thanks a lot.

            1 Reply Last reply
            0

            • Login

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