Results 1 to 5 of 5

Thread: Best way to "include" the images of an application

  1. #1
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Thumbs up Best way to "include" the images of an application

    Hi all, I don't have much experience creating GUI applications and I would like to know what's the best/cleaner/common way to include the images (button icons, background images, etc) that the applications uses. I've thought in various solutions: placing all in a specified directory inside the app directory, including them in the executable,... Could you suggest me something? Thanks.
    Last edited by SkripT; 18th April 2006 at 17:31.

  2. #2
    Join Date
    Apr 2006
    Location
    Rheinland-Pfalz (Germany)
    Posts
    18
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: Best way to "include" the images of an application

    hi,

    use the resource system from Qt4, i mean put all picture in one directory or so and
    create an qrc file like: application.qrc.

    open the file and enter the follow lines:

    Qt Code:
    1. <RCC>
    2. <qresource prefix="/pic" >
    3. <file>picture1.png</file>
    4. </qresource>
    5. </RCC>
    To copy to clipboard, switch view to plain text mode 

    save and close. open the pro file and add this line:
    RESOURCES += application.qrc

    you can use it as example:
    Qt Code:
    1. tBtn = new QToolButton( "nothing to have :)" );
    2. tBtn->setIcon( QPixmap( ":/pic/picture1.png" ) );
    To copy to clipboard, switch view to plain text mode 

    i hope this help you
    Last edited by ChMaster; 18th April 2006 at 17:43.
    Best regeards/kinds

    ChMaster

    Projects:
    DBoxFE
    DMS
    First4 (Plugin developer)

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

    SkripT (18th April 2006)

  4. #3
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Best way to "include" the images of an application

    Quote Originally Posted by SkripT
    Hi all, I don't have much experience creating GUI applications and I would like to know what's the best/cleaner/common way to include the images (button icons, background images, etc) that the applications uses. I've thought in various solutions: placing all in a specified directory inside the app directory, including them in the executable,... Could you suggest me something? Thanks.
    It's up to you. I prefer to embed them in the executable, because:

    a) Overall, your distribution will take up less space than if it contains a folder of separate image files.
    b) The images should load slightly faster, since they are already in memory.
    c) The integrity of the images in your program is not compromised - users cannot change them, delete them etc.

    You can use the Qt resource system to do this.

    However, if you are not fussy about the size of your package (no pun intended) and you would like to allow users to customize the images in your app (a basic form of skinning) then feel free to place them in a separate images directory.
    Save yourself some pain. Learn C++ before learning Qt.

  5. The following user says thank you to Chicken Blood Machine for this useful post:

    SkripT (18th April 2006)

  6. #4
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Best way to "include" the images of an application

    Thanks a lot both. These posts have been very helpful
    Last edited by SkripT; 18th April 2006 at 18:34.

  7. #5
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Best way to "include" the images of an application

    Quote Originally Posted by SkripT
    Thanks a lot both. These posts have been very helpful

    EDIT: I still have a little question: Will the method commented by ChMaster integrate the images in the executable file using the resource file?
    Yes it will.
    Save yourself some pain. Learn C++ before learning Qt.

  8. The following user says thank you to Chicken Blood Machine for this useful post:

    SkripT (18th April 2006)

Similar Threads

  1. QSkinWindows Classes
    By kernel_panic in forum Qt-based Software
    Replies: 45
    Last Post: 20th April 2010, 12:35
  2. Qt Application + Web Integration -- Help needed
    By swamyonline in forum Qt Programming
    Replies: 0
    Last Post: 17th February 2009, 11:59
  3. Embedding images in a Qt3 application
    By Valheru in forum Qt Programming
    Replies: 1
    Last Post: 20th November 2007, 19:25
  4. dll + application
    By fpujol in forum Qt Programming
    Replies: 11
    Last Post: 15th April 2007, 18:37

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
  •  
Qt is a trademark of The Qt Company.