PDA

View Full Version : Inserting non English string into PlainTextEdit



soulless
13th February 2010, 16:45
Hi all,

I create a plain text edit on a widget in designer. when I set the plainText property in designer to s.th like "تست" there's no problem and it works properly, but when I use code to do that:



ui->PlainTextEdit->setPlainText("تست");


the text appear in the plain text edit is s.th like: ???

- Default file encoding of my project is UTF-8
- I changed the locale in designer too but it was not the solution
- I read Internationalization with Qt. I don't want my app support multi languages. I want it just be in my language.

should I make the program in English and then translate it?
any hint?

Lykurg
13th February 2010, 17:23
You have to use QString::fromUtf8() or better use QObject::trUtf8().

soulless
13th February 2010, 18:33
You have to use QString::fromUtf8() or better use QObject::trUtf8().

I opened my cpp file with an external editor and realize that it's encoded in ASCII !!!! I saved it in utf-8 and used what you said. Everything is fine now, tnx.