You can display your text without changing codec:
#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();
}
#include <QApplication>
#include <QLabel>
int main(int argc, char **argv) {
QApplication app(argc, argv);
QLabel label(QString::fromWCharArray(L"Chà o tất cả các bạn!"));
label.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Edit:
this is not really good, because of dynamic translations, but this should work ok:
#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();
}
#include <QApplication>
#include <QLabel>
int main(int argc, char **argv) {
QApplication app(argc, argv);
QLabel label(Qbject::trUtf8("Chà o tất cả các bạn!"));
label.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
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:
#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();
}
#include <QApplication>
#include <QLabel>
int main(int argc, char **argv) {
QApplication app(argc, argv);
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
QLabel label(Qbject::tr("Chà o tất cả các bạn!"));
label.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks