From 6353c1637849d5ac17f5514bd430726458037a20 Mon Sep 17 00:00:00 2001 From: Sami Shalayel Date: Tue, 7 Nov 2023 10:21:29 +0100 Subject: [PATCH] TextEditor example: open file as text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The texteditor is made to open text, and in this case it makes sense to pass the Text flag to the QFile::open call in the example code. Pick-to: 6.5 Task-number: QTBUG-118636 Change-Id: I936610945aa6e2f67b29ce6f5c559a2b942fc718 Reviewed-by: Fabian Kosmale Reviewed-by: Shawn Rutledge Reviewed-by: Olivier De Cannière (cherry picked from commit 743065d7fe2337aa7229a9ea6d4f9b3c30fa1af0) Reviewed-by: Qt Cherry-pick Bot --- examples/quickcontrols/texteditor/documenthandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/quickcontrols/texteditor/documenthandler.cpp b/examples/quickcontrols/texteditor/documenthandler.cpp index f6ed6aef84..471ae59b75 100644 --- a/examples/quickcontrols/texteditor/documenthandler.cpp +++ b/examples/quickcontrols/texteditor/documenthandler.cpp @@ -154,7 +154,7 @@ void DocumentHandler::load(const QUrl &fileUrl) if (QFile::exists(fileName)) { QMimeType mime = QMimeDatabase().mimeTypeForFile(fileName); QFile file(fileName); - if (file.open(QFile::ReadOnly)) { + if (file.open(QFile::ReadOnly | QFile::Text)) { QByteArray data = file.readAll(); if (QTextDocument *doc = textDocument()) { doc->setBaseUrl(path.adjusted(QUrl::RemoveFilename));