[Development] Qml: fast-path loading of custom URLs
416365416c at gmail.com
Thu Jul 25 20:19:25 CEST 2013
On Thu, Jul 25, 2013 at 9:34 AM, Josh Faust <jfaust at suitabletech.com> wrote:
>> It used to be that the QQmlEngine docs said to set a custom
>> QNetworkAccessmanager for intercepting file access, but this had three
>> important drawbacks
>> 1) You have to use a custom URL everywhere
>> 2) You take the slow path when you don't actually need to
> Is there any plan for allowing the fast path through custom URLs? We have an
> internal system similar to qrc, which we currently have to use QNAM to
> One possibility is to allow custom handlers for qrc paths, e.g.:
> QResource::registerHandler("my_custom_root_directory", my_handler);
> We could then use QQmlAbstractUrlInterceptor to translate custom URLs into
> qrc paths. This is a bit roundabout, but would also allow things like
> path-based imports to work.
Yes, this should work. In the end you need to return a file or qrc (or
bundle) path so that it's something which the engine knows how to
synchronously load, but QQmlAbstractUrlInterceptor does cover all URLs
not just strictly fast path ones.
> Alternatively, being able to mark a NetworkReply as immediately finished
> would get most of the way there. This would require changes in a lot of
> loading paths that use the URL to determine if the file is local or remote.
We have that, in that you can mark a reply as finished immediately and
then it will continue to load it synchronously. But that's still
taking a slightly slower path and counts as a remote resource (which
restricts the behavior slightly, such as requiring qmldir files and
restricting plugin loading).
> Has something like QResource::registerHandler() been considered in the past?
> Are there any drawbacks to that approach?
I haven't considered that approach, and don't know much about it (or
More information about the Development