3

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.

kien bui
  • 1,760
  • 2
  • 17
  • 33
  • but I need change many times for many files, right? – kien bui Apr 13 '18 at 02:20
  • Yes. You can *add* a prefix for all files, but you cannot *remove* one. The only solution is to restructure your project (or use symlinks, if your platform supports them). – ekhumoro Apr 13 '18 at 16:48

1 Answers1

2

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.

Bobur
  • 545
  • 1
  • 6
  • 21
  • I must add alias one by one file, right? And then change path on .ui file. – kien bui Apr 13 '18 at 06:04
  • 1
    Yes, You add alias for each file, use alias in GUI. Next time, when you want to change file paths, you will change only resource file and GUI still can access file through alias. – Bobur Apr 13 '18 at 06:23
  • 1
    Note, that the alias can be any text, so the file extension isn't required, unless desired. – TheDarkKnight Apr 13 '18 at 09:27