QTextStream no longer supports QTextCodec.

This commit is contained in:
Roman Telezhynskyi 2023-02-09 17:13:01 +02:00
parent 1a2374e64e
commit e8ee6a50ce

View File

@ -221,7 +221,11 @@ void QxtCsvModel::setSource(QIODevice *file, bool withHeader, QChar separator, Q
QChar ch, buffer(0); QChar ch, buffer(0);
bool readCR = false; bool readCR = false;
QTextStream stream(file); QTextStream stream(file);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
codec ? stream.setCodec(codec) : stream.setAutoDetectUnicode(true); codec ? stream.setCodec(codec) : stream.setAutoDetectUnicode(true);
#else
stream.setAutoDetectUnicode(true);
#endif
while (not stream.atEnd()) while (not stream.atEnd())
{ {
if (buffer != QChar(0)) if (buffer != QChar(0))
@ -606,10 +610,12 @@ bool QxtCsvModel::toCSV(QIODevice* dest, QString &error, bool withHeader, QChar
} }
} }
QTextStream stream(dest); QTextStream stream(dest);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (codec) if (codec)
{ {
stream.setCodec(codec); stream.setCodec(codec);
} }
#endif
if (withHeader) if (withHeader)
{ {
data = QString(); data = QString();