Solved Linguist: how to dynamically switch language of all UI?
-
Question 1) What is the simple way to do this? Question 2) For example: class ZWgtItem::public QWidget{ private: QLabel * mMainTitle,*mSubTitle; } I had many ZWgtItem widget items, so how to translate when change language? Thanks.
-
Hi,
It's described in the Internationalisation chapter in Qt's documentation.
-
@SGaist Thanks, but this is not suitable for me.
I had so many ZWgtItem widgets dynamically new from source code.
So it would be awful to do translate like this:changeEvent(){
******
QVector<ZWgtItem*> wgtlist;
//Language change
for(int i=0; i<wgtlist.length(); i++){
if(i==0)
wgtlist[i].setMainTitle(tr("xxxxx"));
else if(i==1)
wgtlist[i].setMainTitle(tr("yyyyy"));
else if(i==2)
wgtlist[i].setMainTitle(tr("zzzzz"));
.................}
}
-
@brucezcg
Hi
That IS the only way of doing dynamic language changing. ( reset the text again so TR macro can lookup new text)
Alternatively, you can restart the application. -
@mrjj I wanna cry.
But Thanks a lot.