Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Translate model c++
Forum Updated to NodeBB v4.3 + New Features

Translate model c++

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
6 Posts 5 Posters 788 Views 3 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.
  • F Offline
    F Offline
    Fian
    wrote on last edited by
    #1

    Hi, I am trying to translate a model in c ++ with tr () QLinguist, .ts, etc; but it doesn't translate.
    The elements of qml with qsTr () do translated but the c ++ elements with tr () or with any other macro to mark for translation, it did not work.

    QLinguist detects the Qstring between tr () but when I load the .qm once translated with the QLinguist, it does not produce the change, you only change those of the qml with qsTr () but those of the c ++ model do not. The data is loaded into a ListView and created with a delegate that takes the values ​​of the c ++ model

    mzimmersM VRoninV J.HilkJ 3 Replies Last reply
    0
    • F Fian

      Hi, I am trying to translate a model in c ++ with tr () QLinguist, .ts, etc; but it doesn't translate.
      The elements of qml with qsTr () do translated but the c ++ elements with tr () or with any other macro to mark for translation, it did not work.

      QLinguist detects the Qstring between tr () but when I load the .qm once translated with the QLinguist, it does not produce the change, you only change those of the qml with qsTr () but those of the c ++ model do not. The data is loaded into a ListView and created with a delegate that takes the values ​​of the c ++ model

      mzimmersM Offline
      mzimmersM Offline
      mzimmers
      wrote on last edited by
      #2

      @Fian generally, questions like this get answered faster (and more completely) when the poster (you) can provide a code snippet and output messages, rather than verbally summarizing what's going on.

      1 Reply Last reply
      2
      • F Fian

        Hi, I am trying to translate a model in c ++ with tr () QLinguist, .ts, etc; but it doesn't translate.
        The elements of qml with qsTr () do translated but the c ++ elements with tr () or with any other macro to mark for translation, it did not work.

        QLinguist detects the Qstring between tr () but when I load the .qm once translated with the QLinguist, it does not produce the change, you only change those of the qml with qsTr () but those of the c ++ model do not. The data is loaded into a ListView and created with a delegate that takes the values ​​of the c ++ model

        VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #3

        @Fian said in Translate model c++:

        Qstring between tr ()

        tr sould only literal constants

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        1
        • F Fian

          Hi, I am trying to translate a model in c ++ with tr () QLinguist, .ts, etc; but it doesn't translate.
          The elements of qml with qsTr () do translated but the c ++ elements with tr () or with any other macro to mark for translation, it did not work.

          QLinguist detects the Qstring between tr () but when I load the .qm once translated with the QLinguist, it does not produce the change, you only change those of the qml with qsTr () but those of the c ++ model do not. The data is loaded into a ListView and created with a delegate that takes the values ​​of the c ++ model

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @Fian

          the QML engine does an expensive reevaluation of all bindings/assignments when the language changes, so you do not have to do much, to see the new strings.

          On the c++ side of things its a but more complicated. Like @mzimmers said, I have no idea how your code is structured, and how you pass the model to QML.

          Changes are high, that your model is loaded in memory in the beginning of the app, and not reconstructed/reloaded when the language changed -> therefore old string will still be present


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply
          3
          • F Offline
            F Offline
            Fian
            wrote on last edited by
            #5

            thanks to both of you. In the end I decided to use files to save the translations without using the QLinguist. Thanks for answering me :)

            Pablo J. RoginaP 1 Reply Last reply
            0
            • F Fian

              thanks to both of you. In the end I decided to use files to save the translations without using the QLinguist. Thanks for answering me :)

              Pablo J. RoginaP Offline
              Pablo J. RoginaP Offline
              Pablo J. Rogina
              wrote on last edited by
              #6

              @Fian said in Translate model c++:

              I decided to use files

              It looks like your issue is solved. If so, please don't forget to mark your post as solved!

              Upvote the answer(s) that helped you solve the issue
              Use "Topic Tools" button to mark your post as Solved
              Add screenshots via postimage.org
              Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

              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