In Qt 4, C strings are, by default, treated as 7-bit ASCII when
converted to QStrings, and, to get them to be treated as UTF-8, you need to call the setCodecForCStrings method of the QTextCodec class to set the codec to a UTF-8 codec. In Qt 5, C strings are treated always as UTF-8 when converted to QStrings, and there's no setCodecForCStrings method for the QTextCodec class. In addition, there's also no setCodecForTr method for the QTextCodec class - and QObject isn't documented as even *having* a tr method, so I don't know what to do there. svn path=/trunk/; revision=47436
This commit is contained in:
parent
e03896a364
commit
e62aba38e6
@ -121,7 +121,9 @@
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDateTime>
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
|
||||
#include <QTextCodec>
|
||||
#endif
|
||||
#include <qtranslator.h>
|
||||
#include <qlocale.h>
|
||||
#include <qlibraryinfo.h>
|
||||
@ -538,10 +540,15 @@ int main(int argc, char *argv[])
|
||||
qtTranslator.load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
||||
ws_app.installTranslator(&qtTranslator);
|
||||
|
||||
// In Qt 5, C strings are treated always as UTF-8 when converted to
|
||||
// QStrings; in Qt 4, the codec must be set to make that happen
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
|
||||
// Hopefully we won't have to use QString::fromUtf8() in as many places.
|
||||
QTextCodec *utf8codec = QTextCodec::codecForName("UTF-8");
|
||||
QTextCodec::setCodecForCStrings(utf8codec);
|
||||
// XXX - QObject doesn't *have* a tr method in 5.0, as far as I can see...
|
||||
QTextCodec::setCodecForTr(utf8codec);
|
||||
#endif
|
||||
|
||||
main_w = new(MainWindow);
|
||||
// w->setEnabled(false);
|
||||
|
Loading…
x
Reference in New Issue
Block a user