Results 1 to 14 of 14

Thread: rcc question

  1. #1
    Join Date
    Oct 2008
    Posts
    7
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default rcc question

    Hi,

    I use rcc to get a all-in-one exe, with all scripts, pixmaps embeded.
    It's exactly what I need for the customer part, but.....
    When developing, it's a pain since I need to recompile every time I change a script.

    Is there a way to switch from embeded to non embeded ?

    Should I forget rcc and use another tool ?

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: rcc question

    What exactly would you like to do? Keep the images in the filesystem and only build using resources when you have finished developing your application? If so then a simple solution would be to do it like this:

    Qt Code:
    1. #ifdef WITH_RESOURCES
    2. static QString pixmapPrefix=":";
    3. #else
    4. static QString pixmapPrefix="/complete/path/to/your/images/directory";
    5. #endif
    To copy to clipboard, switch view to plain text mode 
    All you need to do then is to use pixmapPrefix to refer to the images.
    Qt Code:
    1. QPixmap px(pixmapPrefix+"/images/myimage.png");
    To copy to clipboard, switch view to plain text mode 
    If you export this variable to scripts, you can use the same trick there.

    A more elegant but requiring more work solution is to register your own prefix with QAbstractFileEngine that will either use resources or real files.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    mojo2000 (18th November 2009)

  4. #3
    Join Date
    Oct 2008
    Posts
    7
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: rcc question

    Hi,

    Thanks very much for response.
    Your solution solve 90 % my problem...

    But 10% are missing....
    I have a lots of libraries organized inside folders.
    Related scripts, pixmaps are stored inside theses folders. Your solution works but only if I release all theses folders.
    I used to work with freelance designers and with your solution I have to find a way to copy all theses folders (without any source code or privates things) and send them with the exe.
    I think about a script to parse all qrc file and copy data's to the "pixmapPrefix" folder.

    Is there another clever solution ?

    Thanks

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: rcc question

    Quote Originally Posted by mojo2000 View Post
    I used to work with freelance designers and with your solution I have to find a way to copy all theses folders (without any source code or privates things) and send them with the exe.
    You can embed them into the binary and use resources, I don't see a problem. From what I understood the problem was you didn't want the files embedded into the binary while developing the application.

    Did I understand you incorrectly?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #5
    Join Date
    Oct 2008
    Posts
    7
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: rcc question

    Ah yes sorry.
    Freelance designer used to edit pixmaps then restart the application to check the result.
    Thats why I need to give them all pixmaps to re-design with the exe.

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: rcc question

    But what is the problem with my solution then? You can embed the data in the application if you want it or not embed it in the application if you want it. You can even have a solution that first you check if a file exists in the file system and if not, only then access the resources (you'd need your own file engine to do that smoothly).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #7
    Join Date
    Oct 2008
    Posts
    7
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: rcc question

    I explained that your solution implies I give all my project tree (since pixmaps are stored in all projects subdirectory) and I cannot just zip my projects tree, I have first to remove all sensible files like sources, scripts, 3rd party licenses ect...

    That why I'm thinking about a script that parse all qrc in all subdirectoies and copy all referenced file to another directory, zip this directory + exe then ship to the designer.
    With this "solution" I'm sure I release all necessary files, and nothing else.

  9. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: rcc question

    Quote Originally Posted by mojo2000 View Post
    I explained that your solution implies I give all my project tree (since pixmaps are stored in all projects subdirectory) and I cannot just zip my projects tree, I have first to remove all sensible files like sources, scripts, 3rd party licenses ect..
    I don't think my solution implies anything. Maybe I just didn't understand what you want. I still don't.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #9
    Join Date
    Oct 2008
    Posts
    7
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: rcc question

    My project source tree:

    ApplicationA
    |-Bin
    | |main.exe
    |---Src
    | |---Main
    | |main.qrc
    | |-----Png
    | |------icon1.png
    | |------icon2.png
    | |------icon3.png
    |-----Network
    | |network.qrc
    | |-----Png
    | |------icon1.png
    | |------icon2.png
    | |------icon3.png
    |-----Gui
    | |gui.qrc
    | |-----Png
    | |------icon1.png
    | |------icon2.png
    | |------icon3.png
    |-----Crypto
    |crypto.qrc
    |-----Png
    |------icon1.png
    |------icon2.png
    |------icon3.png

    inside main.qrc:

    <RCC>
    <qresource prefix="/main" >
    <file>png/icon1.png</file>
    <file>png/icon2.png</file>
    <file>png/icon3.png</file>
    </qresource>
    </RCC>


    To load the pixmap in main.cpp:
    QPixmap(":/main/png/icon1.pmg")

    Your solution means ":" -> "ApplicationA"
    Then to load the icon:
    QPixmap("ApplicationA/main/png/icon1.png")

    It implies I have to release exactly my project tree + png, but without the rest.

  11. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: rcc question

    If you keep the files as a resource in your binary, you just have to release the binary. Isn't that what you wanted? To have two solutions - one for customers, one for developers?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  12. #11
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: rcc question

    I think he wants three. One for customers, one for developers, and one for the graphics artists. 1st wants all embedded, 2nd wants everything external, and 3rd wants everything external but with all private files removed.

    Maybe the best bet is a directory "rsrc" which all your resources are contained within, then you just copy this directory for 3, or copy everything for 2, and copy nothing for 1.

  13. The following user says thank you to squidge for this useful post:

    mojo2000 (18th November 2009)

  14. #12
    Join Date
    Oct 2008
    Posts
    7
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: rcc question

    Quote Originally Posted by fatjuicymole View Post
    I think he wants three. One for customers, one for developers, and one for the graphics artists. 1st wants all embedded, 2nd wants everything external, and 3rd wants everything external but with all private files removed.
    Exactly but in fact 2) is not required since 3) solve the problem for developer and external freelance designer.

    Quote Originally Posted by fatjuicymole View Post
    Maybe the best bet is a directory "rsrc" which all your resources are contained within, then you just copy this directory for 3, or copy everything for 2, and copy nothing for 1.
    That why I will try to make a script that parse all qrc files, then copy referenced files inside a "rsrc" directory.

    Then for external designer, I just have to launch my script, all resources are then copied to "rsrc" and change ":" by "rsrc/" when loading pixmap.

    This workflow solve my problem but with a script....

  15. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: rcc question

    Write yourself an install script for qmake.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  16. #14
    Join Date
    Oct 2008
    Posts
    7
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: rcc question

    Problem solved !

    I've created a script that search all qrc, then parse them and copy all references files to rsrc directory.
    After that, I have all my resources files inside a common directory rsrc.

    In my application, I have to use QAbstractFileEngineHandler + QAbstractFileEngine to handle filenames starting with ":" and just load files from rsrc directory.

    To deactivate this feature, I just have to comment out the QAbstractFileEngineHandler.

    youhou! No lines from my source code need to be changed !

    Thank you for your help!

Similar Threads

  1. Question about multiple Y axis
    By Vortex in forum Qwt
    Replies: 2
    Last Post: 7th October 2011, 08:39
  2. Replies: 0
    Last Post: 31st May 2009, 16:51
  3. Replies: 1
    Last Post: 15th March 2007, 20:45
  4. Question regarding how to paint after zoom.
    By JonathanForQT4 in forum Qt Programming
    Replies: 2
    Last Post: 26th January 2007, 15:34

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.