Alright, so, indeed, this problem was not a bug in code per se, but a misunderstanding on my part as to how the iOS app sandbox works. I feel a bit silly, but, lesson learned and maybe this will help someone in future.
The lesson is: don't persist an absolute device URL that is based on the value returned by QStandardPaths::writableLocation(QStandardPaths:: AppDataLocation). Instead, store the filename (including extension) and stitch together the absolute URL at runtime. For example:
// main.cpp
MyApp app;
QQmlApplicationEngine engine;
QQmlContext *rootContext = engine.rootContext();
rootContext->setContextProperty("app", &app);
// main.cpp
MyApp app;
QQmlApplicationEngine engine;
QQmlContext *rootContext = engine.rootContext();
rootContext->setContextProperty("app", &app);
To copy to clipboard, switch view to plain text mode
// myapp.h
Q_PROPERTY(QString dataLocation READ dataLocation CONSTANT
)
// myapp.h
Q_PROPERTY(QString dataLocation READ dataLocation CONSTANT)
To copy to clipboard, switch view to plain text mode
// MyView.qml
property var model: ...
property int currentIndex: ...
readonly property url localUrl: "file://" + app.dataLocation + "/" + model.get(currentIndex, <url role>) // <-- gets absolute URL using AppDataLocation and the filename stored in the data layer, at runtime
// MyView.qml
property var model: ...
property int currentIndex: ...
readonly property url localUrl: "file://" + app.dataLocation + "/" + model.get(currentIndex, <url role>) // <-- gets absolute URL using AppDataLocation and the filename stored in the data layer, at runtime
To copy to clipboard, switch view to plain text mode
Bookmarks