[SOLVED] Resources, Internal & External Use



  • I would like to use a set of internal resources and external resources at the same time. I have read and re-read the Qt Resource System document and the QResource class document and still don't really understand how to use the external resources and if I can use both an internal resource and an external resource at the same time. I could find no real examples of using external resources. I have the internal resources working and now want to add an external resource that changes depending on a user selected unit to work on. So I guess I have the following questions:

    1. Can use use both an internal and external resource at the same time?
    2. Do you need to instantiate a QResource object explicitly at any time?
    3. I have read where you call "QResource::registerResource("/path/to/myresource.rcc");" to register and external resource but then how do access a particular file in that resource?
    4. How are the internal and external resources distinguished from each other if they have similar paths?

    As I said, I just could not find any good examples to help me down this path. Thanks for any help resolving these questions.



  • Hi,

    I can't try now but in theory:

    1. YES, you can use all kind of resources
    2. NO
    3. You can access a fie in the resource using the standard path :/<prefix>/<fiilename>
    4. If you need to distinguish you can use the second parameter in QResource::registerResource()

  • Moderators

    Hi,

    1. Yes.
    2. No.
    3. You can specify the mount points (mapRoot) of your resources with
      bool QResource::​registerResource(const QString & rccFileName, const QString & mapRoot = QString()).
      All files (internal and external) are mounted under a common root dir and you access them by either qrc:///... or :/.
    4. You need to choose the mount points properly otherwise it won't work.

  • Moderators

    @mcosta Haha, you were faster :-)



  • Thanks to both of you. I was really not sure what "mapRoot" was for some reason could not find an explanation using search. Let me try this and if it works I will mark as solved.



  • Again, thanks to both of you. Your answered helped me understand the virtual resource path and also helped me understand how the "prefix" attribute in the qrc file is used. I have managed to get most of the way through using Qt using the documentation but the resource topic seems to me to be one that is minimally documented compared to other topics.


  • Moderators

    @RRRitchey You're welcome :-)



Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.