UNICODE UTF-8 String in QT + Eclipse?????
I use Eclipse IDE for C/C++ & QT integration plug-in , but I can not write in Unicode font ?
How to resolve ? Thank every body.
Example: I write : "Chà o tất cả các bạn!" but It show in program: "Chà o t?t c? các b?n"
Re: UNICODE UTF-8 String in QT + Eclipse?????
Hello.
Are You create console application? In IDE displays all right?
Re: UNICODE UTF-8 String in QT + Eclipse?????
HÃ*c.
I use QpushBotton,... not display utf - 8 :(
Re: UNICODE UTF-8 String in QT + Eclipse?????
Ok.
I have done so:
1. Check code page in Eclipse, maybe it different from system code page.
if code page is ok, try to use next:
Code:
//in module with pushbutton
Re: UNICODE UTF-8 String in QT + Eclipse?????
You can display your text without changing codec:
Code:
#include <QApplication>
#include <QLabel>
int main(int argc, char **argv) {
QLabel label
(QString::fromWCharArray(L
"Chà o tất cả các bạn!"));
label.show();
return app.exec();
}
Edit:
this is not really good, because of dynamic translations, but this should work ok:
Code:
#include <QApplication>
#include <QLabel>
int main(int argc, char **argv) {
QLabel label
(Qbject
::trUtf8("Chà o tất cả các bạn!"));
label.show();
return app.exec();
}
edit 2:
try to call QTextCodec::setCodecForTr(QTextCodec::codecForName ("UTF-8")); in your main() function, then you should be able to use regular tr("") method:
Code:
#include <QApplication>
#include <QLabel>
int main(int argc, char **argv) {
QLabel label
(Qbject
::tr("Chà o tất cả các bạn!"));
label.show();
return app.exec();
}
1 Attachment(s)
Re: UNICODE UTF-8 String in QT + Eclipse?????
Quote:
Originally Posted by
kunashir
Ok.
I have done so:
1. Check code page in Eclipse, maybe it different from system code page.
if code page is ok, try to use next:
Code:
//in module with pushbutton
It's code Error :(
Quote:
Originally Posted by
stampede
You can display your text without changing codec:
Code:
#include <QApplication>
#include <QLabel>
int main(int argc, char **argv) {
QLabel label
(QString::fromWCharArray(L
"Chà o tất cả các bạn!"));
label.show();
return app.exec();
}
Edit:
this is not really good, because of dynamic translations, but this should work ok:
Code:
#include <QApplication>
#include <QLabel>
int main(int argc, char **argv) {
QLabel label
(Qbject
::trUtf8("Chà o tất cả các bạn!"));
label.show();
return app.exec();
}
edit 2:
try to call
QTextCodec::setCodecForTr(QTextCodec::codecForName ("UTF-8")); in your main() function, then you should be able to use regular tr("") method:
Code:
#include <QApplication>
#include <QLabel>
int main(int argc, char **argv) {
QLabel label
(Qbject
::tr("Chà o tất cả các bạn!"));
label.show();
return app.exec();
}
The Fisrt code it's Work, but the second and third : Error :(
Attachment 7215
Thank everybody for watching.
Re: UNICODE UTF-8 String in QT + Eclipse?????
Your have error in code:
Code:
QLablel lable (Qbject::tr(...));
//rigth path this
You missed "O" in QObject.
Re: UNICODE UTF-8 String in QT + Eclipse?????
Quote:
Originally Posted by
kunashir
Your have error in code:
Code:
QLablel lable (Qbject::tr(...));
//rigth path this
You missed "O" in QObject.
Oh.Sorry kunashir , I don't see :D
THANK EVERYBODY
My problem is solved.
Cheers.