[Interest] Routing all QML file requests through a custom resource provider
Dmitry Volosnykh
dmitry.volosnykh at gmail.com
Fri Jun 17 11:45:49 CEST 2016
Hi, Max!
To be honest, I did not understand in all the details what you are trying
to achieve. Anyway that looks way complex indeed.
Since you are inclined to pack all you resources into auxiliary file like
zip package, you are surely okay with static content. Having this said, you
should be fine using conventional .qrc files (this is what you named Qt
resource system). These files are easily accessed (i.e. viewed, edited,
etc.) from Qt Creator. Qt Designer tools understand them perfectly fine, as
well. Also, there should be no issues when importing QML components from
your .qml files once you feed QML engine with root .qml file stored inside
.qrc file.
Regards,
Dmitry.
On Fri, Jun 17, 2016 at 12:09 PM Max Savenkov <max.savenkov at gmail.com>
wrote:
> Hello,
>
> Once again, I'm trying to use Qt (in this case, QtQuick/QML) for game
> development. The game is going to store all its resources in a package
> (it might be zip, or a custom format) when deployed, but during
> development, resources are available in the usual filesystem. This
> difference is hidden by game's resource provider, which maps resource
> name to a file or an entry in package.
>
> This works for the game itself, but how can I make QML load images,
> imports and other resources from game's resource provider? (also, I'd
> like to view my QML files in Designer, which means I can't use custom
> image providers in QML code itself)
>
> I see two possibilities, but I'm not sure of either one.
>
> 1) Use dynamic resources produced by rcc. When loading a QML file from
> C++, also load relevant rcc data (from game's resources) and register it
> with Qt resource system to make it accessible. This sounds workable, but
> I'm not sure how exactly to make it happen. Suppose I got a binary
> buffer from game's resources. How do I register it in Qt?
>
> 2) Use a system of crutches.
> * Register Url Interceptor with my QMLEngine, such that:
> - any URL that contains an image is changed into
> "image:/my_resource_provider/imagename.png"
> - any URL that contains qml or qmldir is change into... What? There
> is no way to register a special loader for QML imports. But I guess I
> can change it into a network request, by substituting shcema to, for
> example, "my_provider"
> * Register image provider with name "my_resource_provider" that loads
> images from my resource system.
> * Register a custom network access manager factory/manager/network reply
> that load QML files from my system instead of network. This doesn't
> quite work, however, because QML at some point for whatever reason
> checks that URL used to load qml file is local...
>
> So, I'm stumped. This should be WAY easier... And it was, before
> AbstractFileEngine was made private. But I really don't want to use
> private APIs if I can avoid it.
> An argument against AbstractFileEngine was made, that virtual FS should
> be implemented "at OS level" - but I simply cannot see how a game can
> implement it at OS level, because it's a game 0_o.
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160617/200b1b1e/attachment.html>
More information about the Interest
mailing list