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. **cool functionality** Can the user translate the application at runtime?
Forum Updated to NodeBB v4.3 + New Features

**cool functionality** Can the user translate the application at runtime?

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 473 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.
  • A Offline
    A Offline
    addebito
    wrote on last edited by
    #1

    Hello to everyone,
    I'd like to add a (IMHO) cool functionality to give at my customer a possibility to translate the application at runtime!

    I'd like to reproduce the same behavior of Qt Creator, so double click on a QLabel, or a QPushButton or any widgets to bring up a white line edit where the user can write the best text in his language.

    Do you have any idea... how to do it?
    Thank you, as always.

    J.HilkJ 1 Reply Last reply
    0
    • A addebito

      Hello to everyone,
      I'd like to add a (IMHO) cool functionality to give at my customer a possibility to translate the application at runtime!

      I'd like to reproduce the same behavior of Qt Creator, so double click on a QLabel, or a QPushButton or any widgets to bring up a white line edit where the user can write the best text in his language.

      Do you have any idea... how to do it?
      Thank you, as always.

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

      @addebito hi,

      take a look into the documentation, with this example

      https://doc.qt.io/qt-5/qtlinguist-hellotr-example.html

      it should get you started :)


      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
      0
      • A Offline
        A Offline
        addebito
        wrote on last edited by addebito
        #3

        Hi @J-Hilk ,
        thank you for your kind reply however I know how Qt translation works.
        I already have an application with the GUI runtime translation and without restarting, but now I'd like to give at my customers the possibility to translate the GUI directly with itself.

        As mentioned before, the user should be able to enter in this "runtime translation" with a double click on a widget (as the same behavior of Qt Creator) write the best word in his language and press Return to confirm it.
        Under the wood I'll update the .ts file, rebuild the .qm file and reload it.

        It might work?
        But my first question was... how to do the functionality "double click" on all widgets (like QtCreator GUI side) to translate the text at runtime?

        Thank you.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          MajidKamali
          wrote on last edited by MajidKamali
          #4

          you can either:

          1. subclass each QWidget subclass (QLabel, QPushButton, etc.), which you'd like to apply this double-click feature on it, implement mouseDoubleClickEvent and show a QLineEdit on top of that widget, and so on.
          2. create a QObject-based class and implement eventFilter. then for every QWidget-based widget, installEventFilter on that class' instance. (Im not sure about this to work, actually :) )

          But I don't know how to modify ts and qm files. I think It's better to embed lupdate and lrelease in your application, or take a look at their source code

          A 1 Reply Last reply
          1
          • M MajidKamali

            you can either:

            1. subclass each QWidget subclass (QLabel, QPushButton, etc.), which you'd like to apply this double-click feature on it, implement mouseDoubleClickEvent and show a QLineEdit on top of that widget, and so on.
            2. create a QObject-based class and implement eventFilter. then for every QWidget-based widget, installEventFilter on that class' instance. (Im not sure about this to work, actually :) )

            But I don't know how to modify ts and qm files. I think It's better to embed lupdate and lrelease in your application, or take a look at their source code

            A Offline
            A Offline
            addebito
            wrote on last edited by
            #5

            Thank you at all.

            J.HilkJ 1 Reply Last reply
            1
            • A addebito

              Thank you at all.

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

              @addebito if you plan to update your ts file by hand, take a look at my phrasebook utility tool
              https://github.com/DeiVadder/QtPhrasebookUtilityTool

              I use it to update/patch my ts files, should help you getting started.


              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

              • Login

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