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. How to handle external resources with qmake and QtCreator
QtWS25 Last Chance

How to handle external resources with qmake and QtCreator

Scheduled Pinned Locked Moved Qt Creator and other tools
10 Posts 5 Posters 10.7k 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.
  • K Offline
    K Offline
    kraju
    wrote on last edited by
    #1

    Hello Qt Enthusiasts,

    I have set of resources, that I want to put into external binary (thus my main binary is smaller and easier to update over network, this is embedded device). QtCreator supports resources that are compiled-in, e.g. it is sufficient to add: @RESOURCES += name_of_file.qrc@ into my .pro file and then I see all my resources under Resources tab in project tree (and that's great) so I can add/remove/view them.

    My problem is that using this way, resources are always compiled into final binary.

    Are you aware of any chance to have both at same time:

    1. Resources managed through QtCreator in current, convienent way
    2. Being built as external file (and then loaded from code that I have to add myself of course)

    To be more specific - I have no issues with building resources to external file and use them. But how to manage them from QtCreator then?

    I can of course move resource handling outside the .pro, add own custom makefile to run rcc and/or attach it to QMAKE_EXTERA_TARGES but then I will loose QtCreator GUI advantage.

    Thanks,
    Jakub

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tobias.hunger
      wrote on last edited by
      #2

      I do not fully understand what you want to do.... but you can have several resources per target you build (which will all end up in the same binary) and you can have several targets, too.

      So you can have a library that has its own resources which is used by your application, etc. and even load those dynamically if you need that.

      Of course you can also just copy your files somewhere into the file system and use them from there.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goetz
        wrote on last edited by
        #3

        You can have external resources. Just create an ordinary .qrc file using the XML syntax and call rcc like this:

        @
        rcc -binary -o externalresources.qrb externalresources.qrc
        @

        Then add to your C++ code:

        @
        QResource::registerResource("/path/to/your/externalresources.qrb");
        @

        You can access theses resources as if they were ones compiled into the main executable.

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kraju
          wrote on last edited by
          #4

          Hello,

          Thank you for the answers - however, just like I said - I have no problem with using external resources. It works, exactly like Volker said. I use this way for years. :)

          Issue here is that I want to manage my resources from QtCreator (==have them visible as Resources in QtCreator, in project tree).

          To achieve that, I can add my .qrc file into RESOURCES to .pro file but then - and this is root of problem - QMAKE will generate makefile that will compile them into my final binary.

          Hope now it is more clear. It is more a cosmetic issue, I can still edit my .qrc file by hand and add makefile rule into .pro file, but having this done by QtCreator is much more convienent.

          EDIT:

          With pictures :) I want to have my resources be visible just like that:

          !http://krajewski.org/kraju/res.png(Example)!

          ... and same time having them put to external file, not linked to result binary of project I am working with (what qmake does by default when I add my resource to RESOURCES variable).

          Thanks,
          Jakub

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tobias.hunger
            wrote on last edited by
            #5

            As far as I know that is not possible right now. Please feel free to add a "feature request":http://bugreports.qt.nokia.com/ into our bug tracker:-)

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

              Ok, good to know, thank you very much! :)

              1 Reply Last reply
              0
              • M Offline
                M Offline
                matti-
                wrote on last edited by
                #7

                What's the status on External Binary Resources support? Would be fantastic to have QtCreator somehow provide means for distributing such data files alongside the app binary. It's easy enough to create the file but what about the distribution - I assume I could just stab qtc_packagiung/debian_harmattan rules file to include my external resource binary, but then I'd have to do the same to the Symbian / Android (via Necessitas) counterparts as well?

                Slightly cumbersome but somewhat a must now that my texture images are > 5MB and when using compiled-in resources, the app binary gets so big that it loads for several seconds which is not very good user experience..

                • M

                Author of <a href="http://mmark.777-team.org/">MMark13</a>

                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  tobias.hunger
                  wrote on last edited by
                  #8

                  matti: Maybe you could compile the resources into a library and load that later.

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    matti-
                    wrote on last edited by
                    #9

                    Still theres the issue of packaging the library binary? :) But, after some looking into the issue, it seems DEPLOYMENT .pro directive would the way to go, except for "This is only used on Windows CE and the Symbian platform."..

                    Author of <a href="http://mmark.777-team.org/">MMark13</a>

                    1 Reply Last reply
                    0
                    • T tobias.hunger

                      As far as I know that is not possible right now. Please feel free to add a "feature request":http://bugreports.qt.nokia.com/ into our bug tracker:-)

                      S Offline
                      S Offline
                      sl.sy.ifm
                      wrote on last edited by
                      #10

                      @tobias.hunger

                      As far as I know that is not possible right now. Please feel free to add a "feature request":http://bugreports.qt.nokia.com/ into our bug tracker:-)

                      do I see it correctly that nobody opened a "feature request" for this?

                      at least I wasn't able to find anything about it ... and "resources.prf" also doesn't contain any special handling for binary-qrc
                      ... while I was search I stumbled on "CONFIG += resources_big", which could be an alternative for my issue, but seems poorly documented =/

                      I've got an issue of 10MB of *.png that lead to a *.cpp, which is big for VS2013 32bit compiler ... compiler is running out of heap-memory ... using 32bit-crosscompiler would also help, but is not supported by Creator: https://bugreports.qt.io/browse/QTCREATORBUG-15904

                      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