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
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.
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 [bugreports.qt.nokia.com] into our bug tracker:-)
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..