tags:

views:

64

answers:

2

Hi i have a Qt application and there are several plug-ins attached to the application.

i want to change the language of the program on runtime but i dont know how to do it.

i know i can do it by a call of this code:

ui.retranslateUi(this);

but since there are many plug-ins and many widgets on these plug-ins, it is hard to write this code because of the member ui is private in widgets. i dont want to write a code for each widget class.

do you know a better way of loading new translation files?

A: 

You can send QEvent::LocaleChange to plugins, BUT they need to react for it.

Kamil Klimek
even if they react i should write some code to Widget classes. i cant call ui.retranslateUi from plugin class. ui is private for Widget class.
ufukgun
+1  A: 

Just remove all instances of QTranslator that are in effect and install new ones with the desired language. Qt will automatically send LocaleChange events to all views in your app, even the ones in your plugins. There is no need to send those events manually.

andref