Solved Updating QGraphicsview Items in Multilanguage Qt App
-
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.
-
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.