1
votes

Here i am describing the problem that i faced with Qt resource .rcc file.

first, When i created the .qrc file in my project it will fit all the resources that is added in the qrc, in to executable binary file.

second, rcc file in Qt used for well and optimize resource utilization and when i create it in my project it is still including all the resources (added in .qrc file) into the executable binary file even rcc file already contains all the resources so, my question is why to use this rcc even if resources are included in executable binary file. Why to include redundancy in project??

it may possible i misinterpret something or i am not aware of some points, please correct me if i wrong.

2

2 Answers

2
votes

It's too late for answer, but may be helps anybody.

I've expected similar problem, and used next solution: if you use QtCreator, just wrap your RESOURCES += xxx with config condition in .pro file, like that:

!realbuild {
    RESOURCES += xxx.qrc
}

and set CONFIG+=realbuild to qmake params. What does it given? You may edit your forms with QtCreator's designer, and use resource directly from editor, but it will not be compiled into your target file, resources must be loaded in run-time using QResource::registerResource(). Use can build resources manually, using direct call to rcc tool, or write a simple script, and call it using QMAKE_POST_LINK variable.

Now question is - how to reload resources in run-time?...

0
votes

There are two options for Qt resources:

  • include the .qrc in your .pro file with
 RESOURCES = myapp.qrc
  • create an external binary resource file with rcc, then register it at runtime with
QResource::registerResource("/path/to/myresource.rcc");

Don't do both. i.e. if you previously had the .qrc directly included in your .pro, and now want to include it dynamically, remove the RESOURCES line from the project file and do a clean build. External binary resources are not included in your executable if you don't list them in the RESOURCES setting of your project.