summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2024-03-20 13:02:34 -0700
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2024-03-24 16:49:59 +0000
commit1aebeea6527248d7fb7f7a951ecb8570a710cf63 (patch)
treee614a33dcc5596c0cf29494da8f608f368e15991
parentcc2855912b85a956fdc63be8b4c8daf1d08d45d3 (diff)
PDF multipage example: don't assume http by default
Avoid doing network operations unless a network-specific scheme is given. In fact, network loading is not supported anyway, so QUrl::fromLocalFile() would be just as good for now. But perhaps we could support network loading eventually; and this approach is not harmful in the example in the meantime. You just get a "file not found" error if you give an http(s) URL on the command line. Fixes: QTBUG-123548 Change-Id: I2364fd99396d4d65df92106e45818166ef2abf2f Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> (cherry picked from commit f0aa275be272c3ff8337c1d712f8833f7e5a05a6) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 6d0555d007d7daf482006eebf7d8c5fc1d842f6d) (cherry picked from commit ca424727255c97fb5a14eab48d1ce6f7e9eecf83)
-rw-r--r--examples/pdf/multipage/main.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/examples/pdf/multipage/main.cpp b/examples/pdf/multipage/main.cpp
index 9f9272d69..7f7f08063 100644
--- a/examples/pdf/multipage/main.cpp
+++ b/examples/pdf/multipage/main.cpp
@@ -2,6 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "pdfapplication.h"
+#include <QDir>
#include <QQmlApplicationEngine>
int main(int argc, char* argv[])
@@ -15,7 +16,8 @@ int main(int argc, char* argv[])
engine.load(QUrl(QStringLiteral("qrc:///pdfviewer/viewer.qml")));
app.setFileOpener(engine.rootObjects().constFirst());
if (app.arguments().count() > 1) {
- QUrl toLoad = QUrl::fromUserInput(app.arguments().at(1));
+ // alternatively, use QUrl::fromLocalFile(): network loading is not supported yet
+ QUrl toLoad = QUrl::fromUserInput(app.arguments().at(1), QDir::currentPath(), QUrl::AssumeLocalFile);
engine.rootObjects().constFirst()->setProperty("source", toLoad);
} else {
engine.rootObjects().constFirst()->setProperty("source", QStringLiteral("resources/test.pdf"));