Elmi
Elmi

Reputation: 6213

Where to deploy external resources/files?

within my Qt5 application a file ":items/cube.obj" is accessed (.obj is a 3D format and this comes from a piece of example code).

Where within my project/Qt installation path do I have to deploy this file "cube.obj" to let it work with this funny path name?

Thanks!

Upvotes: 0

Views: 820

Answers (1)

svlasov
svlasov

Reputation: 10455

From docs:

By default, resources are accessible in the application under the same file name as they have in the source tree, with a :/ prefix, or by a URL with a qrc scheme.

Note: forward slash in :/.

  1. If you don't use prefix in .qrc, it would be in items directory next to .pro:

    /path/to/project/myproject.pro
    /path/to/project/items/cube.obj
    

    In this case root prefix is used.

  2. If using non-root prefix, .qrc could be:

    <qresource prefix="/items">
        <file>cube.obj</file>
    </qresource>
    

    and files structure:

    /path/to/project/myproject.pro
    /path/to/project/cube.obj
    
  3. Using alias:

    <qresource prefix="/items">
        <file alias="cube.obj">items/cube.obj</file>
    </qresource>
    

    and files structure:

    /path/to/project/myproject.pro
    /path/to/project/items/cube.obj
    

Upvotes: 1

Related Questions