diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-04-28 13:48:45 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-05-01 18:52:14 +0200 |
commit | 5acc3dd242cdd82e063e8aac3f7ee6cf76bd8fbd (patch) | |
tree | d07bf60cd07cbfd42b97748e70d8bbfad2a2c0f9 /src/gui/doc/snippets | |
parent | a308df82ae5d0ea22f3d86ee63138b3df48ab2a9 (diff) |
Remove a couple of QTextStream usages
Don't use QTextStream to write a QString to a file in UTF-8.
This can be done more easily, by directly converting the
QString to utf-8 and calling write on the io device.
Change-Id: I4b617b342ab339affb396ed49c5a920985d1ddfd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/gui/doc/snippets')
3 files changed, 3 insertions, 12 deletions
diff --git a/src/gui/doc/snippets/textdocument-blocks/mainwindow.cpp b/src/gui/doc/snippets/textdocument-blocks/mainwindow.cpp index 849f0e957f..65f855f977 100644 --- a/src/gui/doc/snippets/textdocument-blocks/mainwindow.cpp +++ b/src/gui/doc/snippets/textdocument-blocks/mainwindow.cpp @@ -154,10 +154,7 @@ bool MainWindow::writeXml(const QString &fileName) QFile file(fileName); if (file.open(QFile::WriteOnly)) { - QTextStream textStream(&file); - textStream.setCodec(QTextCodec::codecForName("UTF-8")); - - textStream << domDocument->toString(1).toUtf8(); + file.write(domDocument->toString(1).toUtf8()); file.close(); return true; } diff --git a/src/gui/doc/snippets/textdocument-frames/mainwindow.cpp b/src/gui/doc/snippets/textdocument-frames/mainwindow.cpp index edfadb4c77..620f41708a 100644 --- a/src/gui/doc/snippets/textdocument-frames/mainwindow.cpp +++ b/src/gui/doc/snippets/textdocument-frames/mainwindow.cpp @@ -159,10 +159,7 @@ bool MainWindow::writeXml(const QString &fileName) QFile file(fileName); if (file.open(QFile::WriteOnly)) { - QTextStream textStream(&file); - textStream.setCodec(QTextCodec::codecForName("UTF-8")); - - textStream << domDocument->toString(1).toUtf8(); + file.write(domDocument->toString(1).toUtf8()); file.close(); return true; } diff --git a/src/gui/doc/snippets/textdocument-tables/mainwindow.cpp b/src/gui/doc/snippets/textdocument-tables/mainwindow.cpp index bd976a8ce4..85e7fc109a 100644 --- a/src/gui/doc/snippets/textdocument-tables/mainwindow.cpp +++ b/src/gui/doc/snippets/textdocument-tables/mainwindow.cpp @@ -202,10 +202,7 @@ bool MainWindow::writeXml(const QString &fileName) QFile file(fileName); if (file.open(QFile::WriteOnly)) { - QTextStream textStream(&file); - textStream.setCodec(QTextCodec::codecForName("UTF-8")); - - textStream << domDocument->toString(1).toUtf8(); + file.write(domDocument->toString(1).toUtf8()); file.close(); return true; } |