Reputation: 2447
I currently have a qml.qrc
file that looks like this:
<RCC>
<qresource prefix="/qml">
<file>qml/components/Icon.js</file>
<file>qml/components/IconButton.qml</file>
<file>qml/components/IconLabel.qml</file>
<file>qml/main.qml</file>
<file>qml/setup/NewProject.qml</file>
<file>qml/setup/Setup.qml</file>
<file>qml/setup/Startup.qml</file>
<file>qml/workspace/AnimationWindow.qml</file>
<file>qml/workspace/DepthChartControls.qml</file>
<file>qml/workspace/NewAnimationWindow.qml</file>
<file>qml/workspace/TraceWindow.qml</file>
<file>qml/workspace/Workspace.qml</file>
<file>qml/workspace/WorkspaceMenuBar.qml</file>
<file>qml/Empty.qml</file>
<file>qml/qmldir</file>
<file>qml/Style.qml</file>
<file>icons/play.svg</file>
</qresource>
<qresource prefix="/icons">
<file>lib/material-design/icons/svg/play.svg</file>
</qresource>
</RCC>
Which makes it so that I have to reference qml files like: engine.load(QUrl("qrc:/qml/qml/main.qml"))
, and when I want to access the icon I have to specify :/icons/lib/material-design/icons/svg/play.svg
. Is there a way that I can simplify the paths, by maybe restricting qresources to a prefixed directory path?
Upvotes: 0
Views: 129
Reputation: 98505
It already is the way you want it to be. You can access the files as
qrc:/qml/Icon.js
qrc:/icons/play.svg
etc.
Generally it works as follows: given
<qresource prefix="PREFIX">
<file alias="ALIAS">QRC_RELATIVE_FILEPATH</file>
</qresource>
the resource is accessed via
qrc:PREFIX/ALIAS
The default value for ALIAS
is the filename (and only filename) from QRC_RELATIVE_FILEPATH
- i.e. the use of the path elements in your example is superfluous, but supported.
Upvotes: 3