PDA

View Full Version : Character encoding in text edit and llne edit



greenvirag
19th January 2009, 13:08
Hi!

I programming in qt for half year, but still now I made just english-language software. Today I would like to make something with hungarian characters, so I should use utf8 or iso 8859-2.

I found this:

QString QObject::trUtf8 ( const char * sourceText, const char * comment = 0, int n = -1 )
and

QString::fromUtf8(" ... ")
- these are good for settings, but how can I get the text of a text edit or a line edit in utf8 format?

Thank you,
greenvirag

aamer4yu
20th January 2009, 04:32
Why dont u use Qt Translations ? Your work wud be much easier.
Have a look at Internationalization with Qt in Qt Assistant

Lesiok
20th January 2009, 07:25
Sorry greenvirag but what is a problem ? QT internaly is working in Unicode. All is described in documentation (http://doc.trolltech.com/4.4/i18n.html)

greenvirag
20th January 2009, 08:45
Sorry, I asked wrong question.

I don't need Qt Translation, because the language of the software will be english. But maybe, some user will upload some string using special characters. I get this string:



QString description = ui.textEdit->toPlainText();
QString sname = ui.nameLineEdit->text();


and ok, it can really show these characters. But I need to convert these variables to char*, keeping the special characters.

My problem, that I didn't see at the first time, is that after the QString --> char* conversation the special characters will be lost.