Reputation: 705
I'm developing a C++ program with Qt 4.5 and I'd like to configure my resource file (.qrc) with several resource path. To do so I'd like to add some subpath, but it seems it does not work if I try to add a under another one. Does anybody knows if this is possible? I didn't see anything about this in the doc.
For example, here is what I tried:
<RCC>
<qresource prefix="/path1">
<qresource prefix="subpath1">
<file alias="file1">...</file>
</qresource>
<qresource prefix="subpath2">
<file alias="file2">...</file>
</qresource>
</qresource>
</RCC>
Then trying to access it this way does not work (object is empty):
QImage(":/path1/subpath1/file1")
Note that I already tried to change the qrc file with "/subpath1" instead of "subpath1" without any effect.
Upvotes: 2
Views: 1563
Reputation: 809
Paths in Qt resource files are artificial constructs, therefore you need to explicitly define your path structure by hand (as opposed to xml structure):
<RCC>
<qresource prefix="/path1"/>
<qresource prefix="/path2">
<file>style.css</file>
</qresource>
<qresource prefix="/path1/subpath">
<file>substyle.css</file>
</qresource>
</RCC>
Upvotes: 4