Changing language in Qt on runtime
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 kn开发者_如何学Goow a better way of loading new translation files?
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.
You can send QEvent::LocaleChange
to plugins, BUT they need to react for it.
精彩评论