Qt:Resource
lastmod 2014-02-16created 2014-02-162 edits
The Qt resource system is a platform-independent mechanism for storing binary files in the application's executable. This is useful if your application always needs a certain set of files (icons, translation files, etc.) and you don't want to run the risk of losing the files.
Resource Collection Files
The resources associated with an application are specified in a .qrc file, an XML-based file format that lists files on the disk and optionally assigns them a resource name that the application must use to access the resource.
Here's an example .qrc file:
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>images/copy.png</file>
<file>images/cut.png</file>
<file>images/new.png</file>
<file>images/open.png</file>
<file>images/paste.png</file>
<file>images/save.png</file>
</qresource>
</RCC>
How to use
Create a resources.qrc file with the following content in the same location as the source code.
Finally, add the following line to the project file (.pro).
A path starting with :/ is a path to a resource file. When loading a file added as a resource like this from the actual source code, you must enter a path starting with :./ is the path specified as prefix in the resource list file; if you had specified prefix=”/rsc”, you would have to use :/rsc/img/document-new.png instead of .:/img/document-new.png