Results 1 to 8 of 8

Thread: Relase build has no images (PNG) yet Debug does

  1. #1
    Join Date
    Aug 2006
    Location
    Madison, WI USA
    Posts
    153
    Thanks
    35
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Question Relase build has no images (PNG) yet Debug does

    Windows XP SP3
    Visual Studio 2005
    Qt 4.6.2 (same problem with 4.5.2)

    I build my program in both Debug and Release modes. In the debugger I can see all my icons but running the Release version - no icons (png, jpg, svg). I'm using the Qt resource compiler for my images (this should embed the images into the executable corrrect?).

    I thought maybe I needed the '/imageformats' directory but this made no difference (even after adding 'QCoreApplication::addLibraryPath("Z:/MyAppDir/imageformats");' to my QMainWindow constructor).

    I add icons using 'const QString' or explicit strings like:
    Qt Code:
    1. setWindowIcon( QIcon( ":/images/monkey_on_128x128.png" ) );
    To copy to clipboard, switch view to plain text mode 
    In the resouces.qrc file this image is listed as:
    Qt Code:
    1. <file>../images/monkey_on_128x128.png</file>
    To copy to clipboard, switch view to plain text mode 
    I've tried running the executable from the Release directory and the project root directory but, alas, no images appear. I have also created the icon and dump the result (null or not) to my log file. The images never report that they are null.

    I went through the forum but saw nothing about this particular situation. Does anyone have any suggestions for me to try?
    Last edited by mclark; 18th May 2010 at 22:57. Reason: Changed title

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Relase build has no images yet Debug does

    Try to set an alias for your file. I think otherwise you have to use exactly the same name as the value of file. In your case with "../".
    Did you use the sdk or have you build Qt yourself?

  3. #3
    Join Date
    Aug 2006
    Location
    Madison, WI USA
    Posts
    153
    Thanks
    35
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Relase build has no images yet Debug does

    Did you use the sdk or have you build Qt yourself?
    I'm using a commercial build of Qt 4.6.2

    I'll try the alias test but wouldn't not using an alias be a problem for the Debug build too?

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Relase build has no images yet Debug does

    Ok, sorry, I hadn't noticed, that in debug mode it works, only in release mode it doesn't.

    Are you sure, you have the needed plugins build in release mode? In debug you obviously have, if you see the images...


    EDIT: Because if it works on debug and not on release mode, the only reason could be missing (release mode) libraries.

  5. #5
    Join Date
    Aug 2006
    Location
    Madison, WI USA
    Posts
    153
    Thanks
    35
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Unhappy Re: Relase build has no images yet Debug does

    Try to set an alias for your file.
    I went from:
    <file>../images/monkey_on_128x128.png</file>
    to
    <file alias="monkey_on_128x12.png">../images/monkey_on_128x128.png</file>
    and when creating the QIcon:
    QIcon(":/images/monkey_on_128x12.png")
    to
    QIcon("monkey_on_128x12.png")
    with no change in the output in the Release build (still missing). On the other hand, this image is now missing from the Debug build!

    Are you sure, you have the needed plugins build in release mode?
    I believe that the png files should be handled internally by Qt for both builds. The jpg and svg may need the plugins. In my 'Z:\MyAppDir\imageformats' directory I have: qjpeg4.dll and qsvg4.dll, which are part of the Qt commercial release build (as opposed to qjpegd4.dll).

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Relase build has no images yet Debug does

    Quote Originally Posted by mclark View Post
    and when creating the QIcon:
    Qt Code:
    1. QIcon(":/images/monkey_on_128x12.png")
    To copy to clipboard, switch view to plain text mode 
    to
    Qt Code:
    1. QIcon("monkey_on_128x12.png")
    To copy to clipboard, switch view to plain text mode 
    with no change in the output in the Release build (still missing). On the other hand, this image is now missing from the Debug build!
    Are you sure the new line shouldn't be:
    Qt Code:
    1. QIcon(":/monkey_on_128x12.png")
    To copy to clipboard, switch view to plain text mode 
    assuming that the aliased file is still listed inside a:
    Qt Code:
    1. <qresource prefix="/"> ... </qresource>
    To copy to clipboard, switch view to plain text mode 
    block?

  7. #7
    Join Date
    Aug 2006
    Location
    Madison, WI USA
    Posts
    153
    Thanks
    35
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Relase build has no images yet Debug does

    ChrisW67, you are correct. My use of the resource string in QIcon() was incorrect.

    I changed to QIcon( ":/monkey_on_128x128.png" ).

    Again, in Release AND Debug mode, no images.

    Although, on the plus side; I added <file alias="sensor.svg">../images/sensor.svg</file> to the resource file and when calling QGraphicsSvgItem(":/sensor.svg"), the SVG shows up as expected in Debug mode.

    In any case whenever I create an QIcon I check the result using icon.isNull() and dump the result to my log file. In all cases it reports the icon is NOT null.

  8. #8
    Join Date
    Aug 2006
    Location
    Madison, WI USA
    Posts
    153
    Thanks
    35
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Lightbulb Re: Relase build has no (PNG) images yet Debug does [solved]

    The problem is with the way my Visual Studio project is set up. Debug and Release version of the executable are run from different directories BUT the Debug version looks for everything from the ApplicationRoot directory while the Release does not.

    I fixed my problems by:
    1. Having the Release executable placed, not in the Release subdirectory, but in the ApplicationRoot directory
    2. I added this line to my main window constructor to alias the location of my image directory:
      Qt Code:
      1. QDir::setSearchPaths( "icons", QStringList( QDir::currentPath() + "/images" ) );
      To copy to clipboard, switch view to plain text mode 
    3. I removed all image references from my resource (qrc) file
    4. All images referenced internally are now accessed by:
      Qt Code:
      1. QIcon("icons:image_file.png");
      To copy to clipboard, switch view to plain text mode 
    This allows my to add and use images without having to recompile (which this project must do) and makes the executable smaller.
    Last edited by mclark; 19th May 2010 at 22:10. Reason: Problem solved

Similar Threads

  1. Qt + Linux + Eclipse - debug using debug build?
    By will49 in forum Qt Programming
    Replies: 6
    Last Post: 13th April 2012, 06:27
  2. DEBUG macro not defined in debug build using vc++
    By piotr.dobrogost in forum Qt Programming
    Replies: 0
    Last Post: 21st July 2009, 13:07
  3. Replies: 3
    Last Post: 28th December 2007, 11:02
  4. Replies: 2
    Last Post: 8th November 2007, 20:15
  5. How to build in debug mode?
    By Weilor in forum Newbie
    Replies: 5
    Last Post: 15th February 2006, 14:02

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.