Linguist: how to dynamically switch language of all UI?
-
Hi,
It's described in the Internationalisation chapter in Qt's documentation.
-
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"));
.................}
}
-
@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.