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 743065d7fe)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Sami Shalayel 2023-11-07 10:21:29 +01:00 committed by Qt Cherry-pick Bot
parent 70ac45623b
commit 6353c16378
1 changed files with 1 additions and 1 deletions

View File

@ -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));