Search code examples
qtqt-creatorqt-designerqt-resource

How to change all path of resource file on Qt?


I draw GUI for the app and use many icons with resource file path prefix: /ico and path file in the folder of the project: Resources/Images/*.png

So, each uses them in GUI, I must call::/ico/Resources/Images/*.png

Now, I want to call them with a short path such as ico/*.png And GUI used many resources, I need change resource path many times.

UPDATE: resource file:

<RCC>
    <qresource prefix="/ico">
        <file>Resources/Images/ic_add.png</file>
        <file>Resources/Images/ic_add_click.png</file>
        <file>Resources/Images/ic_add_disable.png</file>
        <file>Resources/Images/ic_add_hover.png</file>
        <file>Resources/Images/ic_arrow.png</file>
        <file>Resources/Images/ic_arrow_collapse.png</file>

And in ui file is using this path many times and many where. I think that I can't change step by step anywhere.


Solution

  • From doc, You would use alias attribute of file tag:

    <file alias="cut-img.png">images/cut.png</file>

    The file is then accessible as :/cut-img.png from the application. It is also possible to specify a path prefix for all files in the .qrc file using the qresource tag's prefix attribute:

    <qresource prefix="/myresources"> <file alias="cut-img.png">images/cut.png</file> </qresource>

    In this case, the file is accessible as :/myresources/cut-img.png.