Is there any way how to implement dynamical file-resolver for missing Qml components in QmlEngine? How to implement dynamically loading of external resources to QmlEngine?
I can use following snippet to load qml component from any data stream:
QUrl uri(...)
QByteArray data(...);
QQmlComponent::setData(data,uri);
but when passed component refers to another one (not already loaded), QmlEngine stopped because of missing resource.
Is there any event/callback where it is possible to handle such missing resource?
Added use-case scenario:
We're developing some QML visual components. Some components are implemented as .qml files
and some as QQuickItem
.
For example imagine following situation (it's very simplified):
QmlItem
"DiagramPoint", implemented in point.qmlQmlItem
"Line" implemented in line.qml, class is using "DiagramPoint" itemQQuickItem (c++)
"ConnectedLine" which internally using "Line" objectQmlProject
which using "ConnectedLine" components.
In case that point.qml and line.qml are located on hdd or stored inside Qt Resources, everything works automatically. But what we would like to achieve is to store these files in encrypted form in our internal .dat file
and decode it only on demand.
We're able to decode and load "Line" object from "ConnectedLine" implementation. But in case that "Line" (line.qml) depends on another encrypted file "DiagramPoint" (point.qml), this solution doesn't work.
Another possible solution
Another solution could be to register all decrypted .qml files on application startup and than use it. Something simillar to qmlRegisterType
which allows to register c++ QQuickItems
to QmlEngine
.
Unfortunately none of these methods allow to register Qml snippet from string buffer.