aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2013-02-02 03:59:57 +0000
committerGuy Harris <guy@alum.mit.edu>2013-02-02 03:59:57 +0000
commite62aba38e66a84aa935722517a8f2cba6b7472e9 (patch)
tree28d07c1cb92dbffe1a3aac28dd85adf57cfbdb86 /ui
parente03896a364292e70e50596aef7a369f00715c415 (diff)
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
Diffstat (limited to 'ui')
-rw-r--r--ui/qt/main.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/ui/qt/main.cpp b/ui/qt/main.cpp
index 9a57c68db3..cb1dc3acb3 100644
--- a/ui/qt/main.cpp
+++ b/ui/qt/main.cpp
@@ -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);