Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. External protected resources
Forum Updated to NodeBB v4.3 + New Features

External protected resources

Scheduled Pinned Locked Moved Solved General and Desktop
12 Posts 3 Posters 3.9k 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.
  • md2012M Offline
    md2012M Offline
    md2012
    wrote on last edited by A Former User
    #1

    hello dear programmers .
    as the title said i need to use a external resources file for my project.
    the case is that i have a gallery ,designed and ready but i used Qresource files (.qrc)
    to handle my image + videos.
    the problem is that qrc files in the final compile turn into 1 solid ".exe" which has a
    huge size and it will get bigger because i need to update it's content later on.
    so any suggestion guys?

    raven-worxR 1 Reply Last reply
    0
    • md2012M md2012

      hello dear programmers .
      as the title said i need to use a external resources file for my project.
      the case is that i have a gallery ,designed and ready but i used Qresource files (.qrc)
      to handle my image + videos.
      the problem is that qrc files in the final compile turn into 1 solid ".exe" which has a
      huge size and it will get bigger because i need to update it's content later on.
      so any suggestion guys?

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @md2012
      See this

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      2
      • md2012M Offline
        md2012M Offline
        md2012
        wrote on last edited by
        #3

        ThnQ sir ,i compiled my qrc files into one rcc file.
        but i didn't understood the registerResource part.
        i changed the

        RESOURCES += \
            images.qrc
        

        to

        RESOURCES += \
            images.rcc
        

        and compiled my code again ,now all the images and videos are not loaded.
        i think i should change the typical addresses that i used in my application but don't know how.
        example :

        QPixmap image(":/new/prefix1/imgs/1_02.jpg")
        
        raven-worxR 1 Reply Last reply
        0
        • md2012M md2012

          ThnQ sir ,i compiled my qrc files into one rcc file.
          but i didn't understood the registerResource part.
          i changed the

          RESOURCES += \
              images.qrc
          

          to

          RESOURCES += \
              images.rcc
          

          and compiled my code again ,now all the images and videos are not loaded.
          i think i should change the typical addresses that i used in my application but don't know how.
          example :

          QPixmap image(":/new/prefix1/imgs/1_02.jpg")
          
          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by raven-worx
          #4

          @md2012
          as written on the doc page you need to use QResource::registerResource("/path/to/myresource.rcc"); instead of setting it via the RESOURCES qmake variable. Since you do not want it to be compiled into the binary.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          2
          • md2012M Offline
            md2012M Offline
            md2012
            wrote on last edited by
            #5

            well i removed

            RESOURCES += \
                images.rcc
            

            from the .pro so the resources won't compile into binary .that worked well ,my .exe size decreased about 10 times.
            now i have to use QResource in my code to address the files in the code.

            QResource b;
                 b.registerResource("/images.rcc");
            

            now there is one .qrc file in the images.rcc.
            how should i address the code below for example?

            QMovie *movie = new QMovie(":/new/prefix1/imgs/1.gif");
            
            
            raven-worxR 1 Reply Last reply
            0
            • md2012M md2012

              well i removed

              RESOURCES += \
                  images.rcc
              

              from the .pro so the resources won't compile into binary .that worked well ,my .exe size decreased about 10 times.
              now i have to use QResource in my code to address the files in the code.

              QResource b;
                   b.registerResource("/images.rcc");
              

              now there is one .qrc file in the images.rcc.
              how should i address the code below for example?

              QMovie *movie = new QMovie(":/new/prefix1/imgs/1.gif");
              
              
              raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by raven-worx
              #6

              @md2012
              exactly like you did before.
              If the files are still not loaded there is something wrong with your path. Check the bool return value of registerResource().

              On what platform are you on? Note that the path (/images.rcc) you've posted means different things on unix and windows for example.

              btw. you do not need to create a QResource instance. registerResource() is a static method.
              So use it as i've written (QResource::registerResource()) is enough.

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              md2012M 1 Reply Last reply
              0
              • raven-worxR raven-worx

                @md2012
                exactly like you did before.
                If the files are still not loaded there is something wrong with your path. Check the bool return value of registerResource().

                On what platform are you on? Note that the path (/images.rcc) you've posted means different things on unix and windows for example.

                btw. you do not need to create a QResource instance. registerResource() is a static method.
                So use it as i've written (QResource::registerResource()) is enough.

                md2012M Offline
                md2012M Offline
                md2012
                wrote on last edited by md2012
                #7

                @raven-worx
                i use windows .
                well now i have the code below in my main.cpp

                 QResource::registerResource("/images.rcc");
                

                also i checked the bool return value and you were right output is false.

                qDebug()<<QResource::registerResource("/images.rcc");
                

                but i checked every where i could for the images.rcc include :
                release folder
                debug folder
                build folder
                main folder which the original cpp and header files are stored.

                raven-worxR 1 Reply Last reply
                0
                • md2012M md2012

                  @raven-worx
                  i use windows .
                  well now i have the code below in my main.cpp

                   QResource::registerResource("/images.rcc");
                  

                  also i checked the bool return value and you were right output is false.

                  qDebug()<<QResource::registerResource("/images.rcc");
                  

                  but i checked every where i could for the images.rcc include :
                  release folder
                  debug folder
                  build folder
                  main folder which the original cpp and header files are stored.

                  raven-worxR Offline
                  raven-worxR Offline
                  raven-worx
                  Moderators
                  wrote on last edited by
                  #8

                  @md2012
                  you called the rcc command in some folder, probably it's there (when you didn't change the -o parameter to contain a path).

                  --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                  If you have a question please use the forum so others can benefit from the solution in the future

                  md2012M 1 Reply Last reply
                  1
                  • raven-worxR raven-worx

                    @md2012
                    you called the rcc command in some folder, probably it's there (when you didn't change the -o parameter to contain a path).

                    md2012M Offline
                    md2012M Offline
                    md2012
                    wrote on last edited by
                    #9

                    @raven-worx
                    i know where is the rcc file ,i changed the location of images.rcc to the
                    release folder
                    debug folder
                    build folder
                    main folder which the original cpp and header files are stored.
                    There must be something wrong with accessing the file because im pretty sure the
                    path "/file.format" will lead to the build folder.

                    raven-worxR 1 Reply Last reply
                    0
                    • md2012M md2012

                      @raven-worx
                      i know where is the rcc file ,i changed the location of images.rcc to the
                      release folder
                      debug folder
                      build folder
                      main folder which the original cpp and header files are stored.
                      There must be something wrong with accessing the file because im pretty sure the
                      path "/file.format" will lead to the build folder.

                      raven-worxR Offline
                      raven-worxR Offline
                      raven-worx
                      Moderators
                      wrote on last edited by
                      #10

                      @md2012
                      It depends where the current working directory is set at the time of calling.
                      You can check with QDir::currentPath()

                      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                      If you have a question please use the forum so others can benefit from the solution in the future

                      md2012M 1 Reply Last reply
                      1
                      • raven-worxR raven-worx

                        @md2012
                        It depends where the current working directory is set at the time of calling.
                        You can check with QDir::currentPath()

                        md2012M Offline
                        md2012M Offline
                        md2012
                        wrote on last edited by
                        #11

                        ThnX Again @raven-worx
                        it was pointing to entirely diffresnt drive
                        "C:/Users/MeHrAnM.D"
                        my project path is
                        D:\Qt\Qt5.2.0\Tools\QtCreator\bin\build-tarh_bartar-Desktop_Qt_5_7_1_MinGW_32bit-Release
                        pretty much confusing ,huh?
                        i started the project on Qt 5.2 ,ended up on Qt 5.7 for the android compiler and newer version.
                        QDir::currentPath() showed me that the current working directory was not there.
                        changed the directory of project to there and problem solved.

                        1 Reply Last reply
                        0
                        • mrjjM Offline
                          mrjjM Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          Just as a note.
                          There is also
                          Debug() << "App path : " << qApp->applicationDirPath();

                          Which is where exe is. So I use that for loading files "next" to the exe no matter where is is.
                          debug/release or deployment folder.

                          1 Reply Last reply
                          1

                          • Login

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