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:
parent
70ac45623b
commit
6353c16378
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue