From e588b3c3a1052dfc063c9c058d361347329e7899 Mon Sep 17 00:00:00 2001 From: John Fultz Date: Sat, 15 Jul 2023 21:24:54 -0500 Subject: Make UTF8-encoding of QTextStream work in Qt5 and 6. QTextStream::setCodec() is no longer a thing in Qt6. Most of our call are to set the codec to UTF-8, which happens to be the default encoding in Qt6. So make a macro so this can compile in both Qt5 and Qt6. --- quacker/lister.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'quacker/lister.cpp') diff --git a/quacker/lister.cpp b/quacker/lister.cpp index c3a4ea9..644dd90 100644 --- a/quacker/lister.cpp +++ b/quacker/lister.cpp @@ -22,6 +22,7 @@ using namespace std; #include #include +#include #include "lister.h" #include "customqsettings.h" @@ -233,7 +234,7 @@ void ListerDialog::openFile() if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream stream(&file); - stream.setCodec(QTextCodec::codecForName("UTF-8")); + SET_QTEXTSTREAM_TO_UTF8(stream); QString line; while (!stream.atEnd()) { @@ -429,7 +430,7 @@ QString ListerDialog::writeList(bool alphagrams) } QTextStream stream(&file); - stream.setCodec(QTextCodec::codecForName("UTF-8")); + SET_QTEXTSTREAM_TO_UTF8(stream); QMap map(anagramMap()); -- cgit v1.2.3