aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSami Shalayel <sami.shalayel@qt.io>2023-11-07 10:21:29 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-11-11 10:46:08 +0000
commit6353c1637849d5ac17f5514bd430726458037a20 (patch)
tree5be7ebaa91e9f58bdb2d4fb9c1f598d41f1b1599
parent70ac45623b8305a222397affdbf4865275195703 (diff)
TextEditor example: open file as text
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 <fabian.kosmale@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> (cherry picked from commit 743065d7fe2337aa7229a9ea6d4f9b3c30fa1af0) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--examples/quickcontrols/texteditor/documenthandler.cpp2
1 files changed, 1 insertions, 1 deletions
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));