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. Changing Language at runtime ?
Forum Updated to NodeBB v4.3 + New Features

Changing Language at runtime ?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 1.9k Views 1 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.
  • S Offline
    S Offline
    Sam
    wrote on last edited by
    #1

    Hi ,

    I am stuck at a particular point and need some suggestions about handling multi language support for my application. I have a class that takes an integer value and returns a QString. The values comes from a text file that contains name value pairs like 1234 = ABCD which are read and stored in a QHash.

    For the components/widgets the text values are stored file

    @m_widget->setText(SomeClass::getText(1234,"ABCD"); // "ABCD" - default text if 1234 is not found@
    Now for all my widget I have implemented changeEvent() where I am checking for LanguageChange event and there I call setText() which works perfect. In order to emit LanguageChange I installed a QTranslator on qApp.

    Now my question is how to handle other things, like text value in a textEdit or the items in a QCombobox and other widgets as well ?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      It seems that you would have to either "reload" the widgets if the text are set within the specific widget or handle the LanguageChange from the "containing" widget that sets the text/items etc... (I am not sure if what I said is clear...)

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

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Sam
        wrote on last edited by
        #3

        Thanks,

        I understood but the question is how to proceed with it. I have implemented the base structure at component level.

        For the modules that I have to reload every widget as the they are initialized and loaded in the constructor. If I reload all again then it will be a hectic job for each n every module and also for all the projects O_o

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Do you use only widgets you created and standard Qt widgets ?

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

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Sam
            wrote on last edited by
            #5

            I have my own Ui library, where I have subclassed most of the Qt widgets. So for my projects I am using these custom widgets only.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Then you could move the text setting part in its own function and call it from the constructor and from the changeEvent of your widgets

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

              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