How to handle external resources with qmake and QtCreator

  • Hello Qt Enthusiasts,

    I have set of resources, that I want to put into external binary (thus my main binary is smaller and easier to update over network, this is embedded device). QtCreator supports resources that are compiled-in, e.g. it is sufficient to add: @RESOURCES += name_of_file.qrc@ into my .pro file and then I see all my resources under Resources tab in project tree (and that's great) so I can add/remove/view them.

    My problem is that using this way, resources are always compiled into final binary.

    Are you aware of any chance to have both at same time:

    1. Resources managed through QtCreator in current, convienent way
    2. Being built as external file (and then loaded from code that I have to add myself of course)

    To be more specific - I have no issues with building resources to external file and use them. But how to manage them from QtCreator then?

    I can of course move resource handling outside the .pro, add own custom makefile to run rcc and/or attach it to QMAKE_EXTERA_TARGES but then I will loose QtCreator GUI advantage.


  • I do not fully understand what you want to do.... but you can have several resources per target you build (which will all end up in the same binary) and you can have several targets, too.

    So you can have a library that has its own resources which is used by your application, etc. and even load those dynamically if you need that.

    Of course you can also just copy your files somewhere into the file system and use them from there.

  • You can have external resources. Just create an ordinary .qrc file using the XML syntax and call rcc like this:

    rcc -binary -o externalresources.qrb externalresources.qrc

    Then add to your C++ code:


    You can access theses resources as if they were ones compiled into the main executable.

  • Hello,

    Thank you for the answers - however, just like I said - I have no problem with using external resources. It works, exactly like Volker said. I use this way for years. :)

    Issue here is that I want to manage my resources from QtCreator (==have them visible as Resources in QtCreator, in project tree).

    To achieve that, I can add my .qrc file into RESOURCES to .pro file but then - and this is root of problem - QMAKE will generate makefile that will compile them into my final binary.

    Hope now it is more clear. It is more a cosmetic issue, I can still edit my .qrc file by hand and add makefile rule into .pro file, but having this done by QtCreator is much more convienent.


    With pictures :) I want to have my resources be visible just like that:


    ... and same time having them put to external file, not linked to result binary of project I am working with (what qmake does by default when I add my resource to RESOURCES variable).


  • As far as I know that is not possible right now. Please feel free to add a "feature request": into our bug tracker:-)

  • Ok, good to know, thank you very much! :)

  • What's the status on External Binary Resources support? Would be fantastic to have QtCreator somehow provide means for distributing such data files alongside the app binary. It's easy enough to create the file but what about the distribution - I assume I could just stab qtc_packagiung/debian_harmattan rules file to include my external resource binary, but then I'd have to do the same to the Symbian / Android (via Necessitas) counterparts as well?

    Slightly cumbersome but somewhat a must now that my texture images are > 5MB and when using compiled-in resources, the app binary gets so big that it loads for several seconds which is not very good user experience..

    • M

  • matti: Maybe you could compile the resources into a library and load that later.

  • Still theres the issue of packaging the library binary? :) But, after some looking into the issue, it seems DEPLOYMENT .pro directive would the way to go, except for "This is only used on Windows CE and the Symbian platform."..

  • @tobias.hunger

    As far as I know that is not possible right now. Please feel free to add a "feature request": into our bug tracker:-)

    do I see it correctly that nobody opened a "feature request" for this?

    at least I wasn't able to find anything about it ... and "resources.prf" also doesn't contain any special handling for binary-qrc
    ... while I was search I stumbled on "CONFIG += resources_big", which could be an alternative for my issue, but seems poorly documented =/

    I've got an issue of 10MB of *.png that lead to a *.cpp, which is big for VS2013 32bit compiler ... compiler is running out of heap-memory ... using 32bit-crosscompiler would also help, but is not supported by Creator:

Log in to reply