PDA

View Full Version : Confusions about displaying Chinese in qt applications



furskytl
4th October 2011, 15:08
I am really confused about displaying Chinese!
First,my windows' language is Chinese.To display Chinese in my app,I searched the Internet and found that I could add the following code to my app and used tr() where I wanted to display Chinese.

QTextCodec::setCodecForTr(QTextCodec::codecForName ("GBK"));
To my release,it really worked very well.However,when I opened my app in my friend's computer,it did't work correctly.My friend's os is also win xp in Chinese!
Then I added the following codes to my app rather than the former one.

QTextCodec::setCodecForCStrings(QTextCodec::codecF orLocale());
QTextCodec::setCodecForTr(QTextCodec::codecForLoca le());
It works perfectly whether on my computer or my friend's.
What happens?
And if I run this app on an English os,can it work correctly?If not,what should I do?Thanks!

wysota
10th October 2011, 22:14
How do you place chinese characters in your code? What do you put inside tr() calls?

furskytl
18th October 2011, 15:33
Just like this tr("ä¸*文示例") . And can you be sure thar if I write :

QTextCodec::setCodecForCStrings(QTextCodec::codecF orLocale());
QTextCodec::setCodecForTr(QTextCodec::codecForLoca le());
it will work everywhere?Or what do you think is the right way to display Chinese?Thank you !

wysota
18th October 2011, 17:04
You should place English calls inside tr() and then provide Chinese translation files for QTranslator.

furskytl
19th October 2011, 12:10
Ok!Thanks !I will try soon!