Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Loading Resource files in Desktop/ios application
Qt 6.11 is out! See what's new in the release blog

Loading Resource files in Desktop/ios application

Scheduled Pinned Locked Moved General and Desktop
14 Posts 3 Posters 8.2k Views 1 Watching
  • 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.
  • K Offline
    K Offline
    kloveridge
    wrote on last edited by
    #5

    Ok, I tried the following:

    @qrc:/cube.gly
    qrc:/packets/cube.gly
    qrc:/assets/packets/cube.gly@

    None of these work. qrc:/assets/packets/cube.gly should have been the correct one. But it fails.

    cube.gly is the actual file.

    packets is the prefix

    assets is the .qrc file.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      steno
      wrote on last edited by
      #6

      Oh ok, you only need the prefix and not qrc file name. You do need the Q_INIT_RESOURCE if the qrc is in a library.

      This should have worked.

      @qrc:/packets/cube.gly@

      I can't think right now to help point you in the right direction.

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kloveridge
        wrote on last edited by
        #7

        I'm thinking that this problem is due to the fact that my asset loader is in a library. Does my library .pro file require this?

        @RESOURCES +=
        assets.qrc@

        I figured the resources would be available to all the components in my main application

        1 Reply Last reply
        0
        • S Offline
          S Offline
          steno
          wrote on last edited by
          #8

          Yes, your pro file for your library must have the RESOURCES += so that the qrc file is compiled. All a qrc file is is a xml file. When that file is compiled by the rcc, the output is then used to compile those resources into your binary. To reference those resources, you must use Q_INIT_RESOURCE outside of any namespace.

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

            Hi,

            Something's not clear here. Are you compiling the resources in your application and then try to access them in your library ?

            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
            • K Offline
              K Offline
              kloveridge
              wrote on last edited by
              #10

              SGaist,
              Yes. My library has the file loader in it. When I read from a harddrive, I can specify a path and everything is great.

              But Qt's resource system seems to choke on the same basic design. It doesn't work like a hard drive at all. And another question I have is this. Does it load everything into memory when the app starts up? Thats ridiculous if does. I will be putting hundreds of megabytes of data in here. The idea is I want to load them into memory as I need it-like I do with a harddrive.

              With XCode, I can include assets (ie, image files, data files [such as 3d model assets], etc.) It puts the content in the bundle and I can access it just like I can on my mac--I just need the bundle path. I am having a hard time wrapping my head around how this is done in Qt.

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

                If you plan on hundreds of megabytes then you're using the wrong tool. Qt's resources are not meant to bundle that much data. Each resource will be compiled in your application.

                However you still can use iOS assets, see "here":http://qt-project.org/doc/qt-5/platform-notes-ios.html

                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
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #12

                  Forgot to add to get the path you want you have QStandardPaths

                  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
                  • K Offline
                    K Offline
                    kloveridge
                    wrote on last edited by
                    #13

                    After reviewing your information, its clear I'm taking the wrong approach using a resource file. I understand now what the intent of the resource file is. It isn't to load my image/game assets.

                    On iOS, it looks like I need to look at using QMAKE_BUNDLE_DATA to package up my content. I don't yet know what I am to do on Android. I'm sure I'm going to have a few more questions ;)

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

                      Indeed, game assets are way to heavy for resources.

                      AFAIK, you should be able to use QMAKE_BUNDLE_DATA also on android

                      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

                      • Login

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