Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Updating QGraphicsview Items in Multilanguage Qt App
Qt 6.12 LTS is out! See what's new in the release blog

Updating QGraphicsview Items in Multilanguage Qt App

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

    Hi to all,

    I am working on a project with Qt 5 and I struggle to update QGraphicsItem's texts when I translate the app. There is no problem when I translate a widget which is created in ui file. However, when I create any item in QGraphicsview and put the translated versions on Qt Linguistic, retranslateUi function does not work because it does not cover items which are childs of QGraphicsScene.

    I know that Qt handles translateUi function by itself. For instance, it creates this function below

    pushButton->setText(QCoreApplication::translate("MainWindow", "ChangeEvent", nullptr));
    

    Do i need to write these function manually to update items text in QGraphicsview or is there a quicker way that Qt handles this problem by itself again?

    Thank you.

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

      Hi
      As far as I know, yes its manually.
      You could automate it a bit since all items are in a list and you can loop that and call
      QCoreApplication::translate on each item, however, you need to keep the English text around if you want to allow change languages multiple times in the same session.

      1 Reply Last reply
      1

      • Login

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