aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quickcontrols2/texteditor/documenthandler.cpp
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2016-07-26 14:15:31 +0200
committerMitch Curtis <mitch.curtis@qt.io>2016-08-24 08:09:24 +0000
commita80f50ab9bba8f6f9d19d1edb2eeafce9dcee799 (patch)
treea0af6c8bdc1837e01fc3cd0cedd60077d03d2006 /examples/quickcontrols2/texteditor/documenthandler.cpp
parent0524ddb9489cd9816fadc330f75efc7b40994013 (diff)
texteditor: add touch UI
Task-number: QTBUG-54952 Change-Id: I14fe95608c4393b928edc80fc93ebaa843ce478f Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'examples/quickcontrols2/texteditor/documenthandler.cpp')
-rw-r--r--examples/quickcontrols2/texteditor/documenthandler.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/examples/quickcontrols2/texteditor/documenthandler.cpp b/examples/quickcontrols2/texteditor/documenthandler.cpp
index 45c0f4cb..e57946fd 100644
--- a/examples/quickcontrols2/texteditor/documenthandler.cpp
+++ b/examples/quickcontrols2/texteditor/documenthandler.cpp
@@ -52,7 +52,9 @@
#include <QFile>
#include <QFileInfo>
+#include <QFileSelector>
#include <QQmlFile>
+#include <QQmlFileSelector>
#include <QQuickTextDocument>
#include <QTextCharFormat>
#include <QTextCodec>
@@ -277,7 +279,14 @@ void DocumentHandler::load(const QUrl &fileUrl)
if (fileUrl == m_fileUrl)
return;
- QString fileName = QQmlFile::urlToLocalFileOrQrc(fileUrl);
+ QQmlEngine *engine = qmlEngine(this);
+ if (!engine) {
+ qWarning() << "load() called before DocumentHandler has QQmlEngine";
+ return;
+ }
+
+ const QUrl path = QQmlFileSelector::get(engine)->selector()->select(fileUrl);
+ const QString fileName = QQmlFile::urlToLocalFileOrQrc(path);
if (QFile::exists(fileName)) {
QFile file(fileName);
if (file.open(QFile::ReadOnly)) {