[Interest] Routing all QML file requests through a custom resource provider

Max Savenkov max.savenkov at gmail.com
Fri Jun 17 20:15:10 CEST 2016


Thank you, I've read that link already quite a few times. What I'd like to
know, is how to use "External Binary Resources" if said external resources
are not located on disk, but in memory. However, after a bit of thinking I
decided that it's wouldn't be useful even if it is possible, as I would
have to load the whole resource into application's memory, which is not
acceptable on mobile devices.

Now I see that my options are strictly limited to either keep trying to
implement a VFS in Qt via hacks and crutches, or using separate resource
packages for the game and UI (my own format for game, and qrc/rcc for UI).

2016-06-17 19:47 GMT+03:00 Jason H <jhihn at gmx.com>:

> You can of course use all of Qt without QtCreator. I've done it, and it's
> still possible.
>
> When you have a resource, it becomes availible in the binary's asset
> system, and need not be distributed as a file on disk. This can prevent
> tampering if the binary is signed. Also I would assume that it gets loaded
> in the text segment of the executable and winds up on memory pages without
> the EXEC bit set.
>
> http://doc.qt.io/qt-5/resources.html
>
>
> *Sent:* Friday, June 17, 2016 at 12:37 PM
> *From:* "Max Savenkov" <max.savenkov at gmail.com>
> *To:* "Jason H" <jhihn at gmx.com>
> *Cc:* "Dmitry Volosnykh" <dmitry.volosnykh at gmail.com>, "<
> interest at qt-project.org>" <interest at qt-project.org>
>
> *Subject:* Re: [Interest] Routing all QML file requests through a custom
> resource provider
> OK, but if I do not use QtCreator, is there no way to make it work? What
> does adding a qrc file to RESOURCES actually do (besides triggering
> resource compiler)? I'm looking for an understanding here.
>
> 2016-06-17 19:23 GMT+03:00 Jason H <jhihn at gmx.com>:
>>
>>
>> What Dimitry said plus:
>>
>> Add:
>> CONFIG += resources_big
>>
>>
>> to your .pro file, which should get around some long linking times.
>>
>>
>> --------------------------------------
>> Sent: Friday, June 17, 2016 at 5:45 AM
>> From: "Dmitry Volosnykh" <dmitry.volosnykh at gmail.com>
>> To: "Max Savenkov" <max.savenkov at gmail.com>, "<interest at qt-project.org>"
>> <interest at qt-project.org>
>> Subject: Re: [Interest] Routing all QML file requests through a custom
>> resource provider
>>
>> 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[Interest at qt-project.org]
>>
>> http://lists.qt-project.org/mailman/listinfo/interest_______________________________________________
>> Interest mailing list Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest[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/1fbbfa11/attachment.html>


More information about the Interest mailing list