Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. QRC add folder
QtWS25 Last Chance

QRC add folder

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
7 Posts 2 Posters 3.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bozo6919
    wrote on last edited by bozo6919
    #1

    Hi,

    I'm trying to read a folder's content who contains another folder and files in theses folders.
    The organisation of the content can be resume with the following schema:

    - Ressources
        - fileressource
        - fileressource
        - ...
        - players
            - player1
                - info.txt
                - icon.png
                - sprite.png
            - player1
                - info.txt
                - icon.png
                - sprite.png
        - fileressource
    

    What i want is to get something like this:

        QStringList playersFolder = QDir(":players").entryList(); // Expected { "James", "Maximus" } (without take in account dot and dotdot)
        for (auto playerFolder : playersFolder) {
            QString pathInfo = playerFolder + "/info.txt";
            QString pathIcon = playerFolder + "/icon.png";
            QString pathSprite = playerFolder + "/sprite.png";
        }
    

    But what I have is playersFolder = {"icon.png", "info.png", "James", "Maximus", "sprite.png"}

    My QRC is like this:

    <RCC version="1.0">
        <qresource>
            <file>players</file>
        </qresource>
    </RCC>
    

    So i'm confused

    Sorry for my English ^^'

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #6

      That's not how the resource system is working. You either build the resources as part of your application or build an external binary resource.

      You have all the information you need here.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      B 1 Reply Last reply
      1
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Hi,

        AFAIK, and following the documentation, you are expected to list all files explicitly in the .qrc file. I am currently surprised you are not getting an error when compiling your application.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        B 1 Reply Last reply
        1
        • SGaistS SGaist

          Hi,

          AFAIK, and following the documentation, you are expected to list all files explicitly in the .qrc file. I am currently surprised you are not getting an error when compiling your application.

          B Offline
          B Offline
          bozo6919
          wrote on last edited by
          #3

          @SGaist thanks for your answer, there is no way to don't list all files in the qrc? I want to do this dynamically.

          If there is no way, I'll going to try to add a file resource "folder.json" for example who going to list all directory (name + path)

          Sorry for my English ^^'

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #4

            What do you mean by "I want to do this dynamically" ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • B Offline
              B Offline
              bozo6919
              wrote on last edited by
              #5

              Don't list files in the qrc, simply open the folder and get the content. If I add, for example, new sub-folders into the main-folder, the program doesn't need to be recompiled, when I open the folder, I will see all sub-folders.

              Sorry for my English ^^'

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #6

                That's not how the resource system is working. You either build the resources as part of your application or build an external binary resource.

                You have all the information you need here.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                B 1 Reply Last reply
                1
                • SGaistS SGaist

                  That's not how the resource system is working. You either build the resources as part of your application or build an external binary resource.

                  You have all the information you need here.

                  B Offline
                  B Offline
                  bozo6919
                  wrote on last edited by
                  #7

                  @SGaist Yes, I have already read this document ;) thanks for the explanation !

                  Sorry for my English ^^'

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved