Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Changing Language at runtime ?

    General and Desktop
    2
    6
    1444
    Loading More Posts
    • 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
      Sam last edited by

      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 Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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 Reply Quote 0
        • S
          Sam last edited by

          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 Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            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 Reply Quote 0
            • S
              Sam last edited by

              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 Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                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 Reply Quote 0
                • First post
                  Last post