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. 如何使QT的翻译功能用起来更加简单 如何使QT的翻译功能用起来更加简单 How to make the translation function of QT easier to use
Forum Updated to NodeBB v4.3 + New Features

如何使QT的翻译功能用起来更加简单 如何使QT的翻译功能用起来更加简单 How to make the translation function of QT easier to use

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 514 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.
  • X Offline
    X Offline
    XiaofengXu
    wrote on last edited by
    #1

    With the increasing size of projects, more and more UI controls are used. Every time a control is added, it needs to write a function to receive the LanguageChange event of Qt and call translation related functions in the event. What can be done to make it easier. I hope that each object can automatically translate the text they are responsible for when the LanguageChange event is published.

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

      Creating a base widget that does that handling is the correct way. However you can't optimize more. Each of your widgets will have custom texts and that's normal so streamlining where the code should be is already a good gain.

      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
      • X XiaofengXu

        With the increasing size of projects, more and more UI controls are used. Every time a control is added, it needs to write a function to receive the LanguageChange event of Qt and call translation related functions in the event. What can be done to make it easier. I hope that each object can automatically translate the text they are responsible for when the LanguageChange event is published.

        SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Hi,

        Are you coding all your UIs ?

        If so, you can create a base class that implements the LanguageChange event handling that will call a virtual method named, for example, retranslateUi that you will re-implement in all your widgets. You should call that method from the constructor as well and place there all calls that set translatable texts on 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

        X 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          Are you coding all your UIs ?

          If so, you can create a base class that implements the LanguageChange event handling that will call a virtual method named, for example, retranslateUi that you will re-implement in all your widgets. You should call that method from the constructor as well and place there all calls that set translatable texts on your widgets.

          X Offline
          X Offline
          XiaofengXu
          wrote on last edited by
          #3

          @SGaist Thanks! The current project uses the method you mentioned, but there are many UI controls in QT and customized UI controls in the project, so I wonder if there is a better way.

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

            Creating a base widget that does that handling is the correct way. However you can't optimize more. Each of your widgets will have custom texts and that's normal so streamlining where the code should be is already a good gain.

            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
            • X XiaofengXu has marked this topic as solved on

            • Login

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