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 /examples | |
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 'examples')
-rw-r--r-- | examples/widgets/tools/codecs/mainwindow.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/examples/widgets/tools/codecs/mainwindow.cpp b/examples/widgets/tools/codecs/mainwindow.cpp index dc72fa73b7..dfd2ff452a 100644 --- a/examples/widgets/tools/codecs/mainwindow.cpp +++ b/examples/widgets/tools/codecs/mainwindow.cpp @@ -122,9 +122,9 @@ void MainWindow::save() return; } - QTextStream out(&file); - out.setCodec(codecName.constData()); - out << textEdit->toPlainText(); + QTextCodec *codec = QTextCodec::codecForName(codecName.constData()); + QByteArray text = codec->fromUnicode(textEdit->toPlainText()); + file.write(text); } void MainWindow::about() |