Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Configuring differents resources with qmake command line
Forum Updated to NodeBB v4.3 + New Features

Configuring differents resources with qmake command line

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
7 Posts 3 Posters 2.1k Views 3 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.
  • A Offline
    A Offline
    Adagiow
    wrote on last edited by
    #1

    Hello,

    I would like to have several resource configurations depending on the projects.
    Only, I would like not to configure the resource paths in the file .pro, for not having specific code in the project.

    I want to pass an argument in qmake to specify the resource

    I thought of two solutions :

    1 - add resources path variable in qmake (like CONFIG+=DEFINES+=MY_PATH=\"C:/../path\"). Use this path for load binaries resources rcc

    2 - add resource configuration in qmake (like CONFIG+=RESOURCES+=pathToRessource)

    I do not know if one of the two solutions is feasible, I did not succeed

    One last solution that works but that I do not want is:
    3 - Add PATH_A{ RESOURCES += path_to_resources_a} in .pro, and in qmake command line add : CONFIG+=PATH_A

    Do you have a solution to do that?

    Cordially

    Alexis

    1 Reply Last reply
    0
    • K Offline
      K Offline
      karlheinzreichel
      wrote on last edited by
      #2

      Why not using environment variables which can be set before calling qmake in the command line?

      As you can find in the qmake documentation, qmake can evaluate environment vars at runtime.

      regards
      Karl-Heinz

      1 Reply Last reply
      3
      • A Offline
        A Offline
        Adagiow
        wrote on last edited by
        #3

        Thanks Karl-Heinz,

        Environment variable solution works for load resource file at runtime

        3 steps :

        • create binarie rcc from qrc resource file : rcc -binary myresource.qrc -o myresource.rcc
        • add env variable MY_PATH=path_to_rcc_file. In qtCreator I do : "project->compilation environment->Add"
        • in source code, we load rcc binary at runtime :
        QString my_path(qgetenv("MY_PATH"));
        QResource::registerResource(path); // with #include <QResource> before
        

        Only I realize that this is not what I want :(
        I need to be able to load resources when compiling, to distribute only an executable file (and not exe + rcc file)
        So my solution 1- (proposed in the first message) is wrong

        regards

        Alexis

        K 1 Reply Last reply
        0
        • A Adagiow

          Thanks Karl-Heinz,

          Environment variable solution works for load resource file at runtime

          3 steps :

          • create binarie rcc from qrc resource file : rcc -binary myresource.qrc -o myresource.rcc
          • add env variable MY_PATH=path_to_rcc_file. In qtCreator I do : "project->compilation environment->Add"
          • in source code, we load rcc binary at runtime :
          QString my_path(qgetenv("MY_PATH"));
          QResource::registerResource(path); // with #include <QResource> before
          

          Only I realize that this is not what I want :(
          I need to be able to load resources when compiling, to distribute only an executable file (and not exe + rcc file)
          So my solution 1- (proposed in the first message) is wrong

          regards

          Alexis

          K Offline
          K Offline
          karlheinzreichel
          wrote on last edited by
          #4

          Alexis, i ment usage of environment variables in qmake project files:

          see: http://doc.qt.io/qt-4.8/qmake-advanced-usage.html#variables
          and https://stackoverflow.com/questions/26621709/how-can-i-use-environment-variable-in-a-qt-qmake-file-windows

          regards

          Karl-Heinz

          1 Reply Last reply
          3
          • A Offline
            A Offline
            Adagiow
            wrote on last edited by
            #5

            Thanks
            But, i can't load ressource at runtime. I need to add resource in comiling step as if the resources were added in .pro, but in command line.
            regards

            mrjjM 1 Reply Last reply
            0
            • A Adagiow

              Thanks
              But, i can't load ressource at runtime. I need to add resource in comiling step as if the resources were added in .pro, but in command line.
              regards

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Adagiow

              Hi
              I think karlheinzreichel ment you can use env. variable to select what qres to use

              RESOURCES += $$(XXX_ENV)

              so you can just name it on command line and the qres is then compiled into .exe

              1 Reply Last reply
              5
              • A Offline
                A Offline
                Adagiow
                wrote on last edited by
                #7

                Thanks mrjj and Karl-Heinz,

                Effectively, it's work!

                In qmake command line add RESOURCES+=$$(RPATH2)
                And declare RPATH2=path in env variable

                It must be possible to do it in a script, I use qtCreator for test

                Resources are well embarked in .exe. (for embarked text ressources, I created .ini file and load it with QSettings)

                I can close topici think

                Regards

                1 Reply Last reply
                2

                • Login

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