Results 1 to 16 of 16

Thread: why do icons only show up on my computer ??

  1. #1
    Join Date
    Aug 2012
    Posts
    13
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default why do icons only show up on my computer ??

    Hi
    I am new to qt creator. I want to add an icon to a toolbar so I create a .qrc file which contain some .ico files. The application worked fine until I move it to another computer without Qt creator. The application can still work but the icons are missing. Can anybody tells me how could this happen? Is there any solutions?
    qt.jpg

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: why do icons only show up on my computer ??

    You should deploy the image-plugins with your application and other libraries and then it will work. You can read a little bit more here.
    Last edited by Zlatomir; 23rd August 2012 at 10:03.

  3. #3
    Join Date
    Sep 2012
    Posts
    7
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: why do icons only show up on my computer ??

    Icons show up fine on my system, but when installed on systems without Qt, my custom icon does not display, the default icon displays enstead. However, the Desktop and the Taskbar displays my custom icon just fine.

    I have run the executable through Dependency Walker and all of the displayed dependencies are included in my Setup project/build. Nothing appears to be missing from the build.

    I have a .qrc file with the icon.ico file and an .rc file that has the same. The .rc file provides the icon on the desktop and taskbar. It seems to be working fine.

    The puzzler is the icons show on my system and on another developers system, but not on non-Qt systems.

    System: Win7 64bit, Visual Studio 10, Qt 4.8.1

    Thanks;
    masher333

  4. #4
    Join Date
    Nov 2009
    Posts
    61
    Thanks
    9
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: why do icons only show up on my computer ??

    I have similar problem. I have distributed an app with all libraries, including a *.rcc external binary resource file and register it in the program. It works ok at mine but in another system where Qt is not installed, system tray icon is missing; although, the icon in task bar and window title is visible. Also, system tray icon is missing in MAC OS X. I tried to build the app with external and internal resource file, changed icon form for Win to MAC OS X but sys tray icon is still missing in both Win and Mac OS X; another system is XP Pro without Qt.

  5. #5
    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: why do icons only show up on my computer ??

    The solution is (still) in Zlatomir's post.

  6. #6
    Join Date
    Sep 2012
    Posts
    7
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: why do icons only show up on my computer ??

    ChrisW67



    Re: why do icons only show up on my computer ??
    The solution is (still) in Zlatomir's post.
    Yes, I read the link Zlatomir referenced in his post. I guess it is clear to those who have trodden this ground before and not so clear to those who haven't. I didn't walk away from that read with a clear solution, but since you have recommended it. I will go back and read it more carefully.

    Again, I have run the executable through Dependency Walker on the system that doesn't show the icons and nothing is missing. I don't know what to add, so Zlotamir's solution on how to add by code is only part of the answer. It seems that the graphic/paint supporting lib that Zlotamir is adding is not applicable to my project. Please school me on this.

    Perhaps an example would be most helpful, but alas we don't always get what we want.

    -masher

  7. #7
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: why do icons only show up on my computer ??

    Try converting one of your ico files to png and make sure the png file is added to the qrc resources and compiled into your program. I do this for all of my toolbar icons and do not need to deploy any image handling plugins with my app. Works just fine on a PC with no Qt installed, just the few DLLs that my app needs installed in the app directory along side of the EXE file.

    I have not tried to use an ico file directly, since I get most of my icons in png format. Your problem could be as simple as not having the file built into the resources, but I would try the png conversion first.

  8. #8
    Join Date
    Nov 2009
    Posts
    61
    Thanks
    9
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: why do icons only show up on my computer ??

    @d_stranz. Hi. Do you think there is a problem with rendering icons via ICO files? I am using the same *.ico file for Desktop, windows title, and system tray icons. In my machine, everything works well (Win 7 64bit). On another machine where Qt is not installed, what I know is that system icon is not rendered but all the other looks correct.

  9. #9
    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: why do icons only show up on my computer ??

    The icon (*.ico) you have embedded in Windows resources for display as the application icon is read and interpreted by Windows not Qt. This is why it displays correctly in Windows contexts (desktop, task bar).

    That same *.ico file requires the ICO image format plugin in order for Qt to display it. PNG files work out-of-the box because their processing is built in, other formats (GIF, JPEG, ICO, TIFF, MNG) require a plugin that is loaded (if available) on program start or demand. Dependency Walker (DW) will show you the libraries that are early-bound to the executable, i.e. known to be required up front, when you open the executable. If you run the executable in DW profiling mode you may see other libraries pulled in dynamically. I do not think you will see failures to load the ICO image format plugin because Qt only attempts to load the plugins it finds. On your dev machine the plugins are present and the *.ico file can be displayed by Qt. If you deploy without the relevant image format plugins then the deployed system will be unable to display images of that format: displaying a blank space instead of crashing.

    The solution is simply to create a folder called imageformats next to your deployed executable and place qico4.dll in that folder.
    Here is an example layout

  10. The following 3 users say thank you to ChrisW67 for this useful post:

    masher (20th September 2012), ZikO (20th September 2012), Zlatomir (20th September 2012)

  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: why do icons only show up on my computer ??

    Quote Originally Posted by masher View Post
    Again, I have run the executable through Dependency Walker on the system that doesn't show the icons and nothing is missing.
    The dependency walker only shows dependecies that are statically declared when building the application, not those that arise dynamically (like when using plugins). The dependency walker has no way of knowing that a concrete plugin is required for your application to read ICO 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.


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

    Zlatomir (20th September 2012)

  13. #11
    Join Date
    Sep 2012
    Posts
    7
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: why do icons only show up on my computer ??

    I need to make a correction to my previous statement...

    Static declarations are detected in Dependency Walker when you drag yourExecutable.exe and place it in the Dependency Walker's main window. However, what I learned yesterday is that Dependency walker will find dynamic dependencies also.

    Dynamic dependencies are found by running a Static detection and then using the "Profile" pulldown menu and selecting "Start Profiling".

    This will show you everytime that your executable called upon qtcore4.dll AND what qtcore4 called, that is how I confirmed that I also needed to add the qico4.dll as well as the qjpeg4.dll to my VS setup project. This will actually execute your app in the process. It is a very cool feature of Dependency Walker of which I was unaware.

    Anyway, because I did not know that I could use Dependency Walker to find Dynamic Dependencies; I incorrectly stated that I did not know what dependencies I was missing. I hope this helps.

    This forum, or more accurately the Members of this forum have been very helpful!

    Thanks;
    masher
    PS: If your app is 32bit then you must use the 32bit version of Dependency Walker, or 64bit for a 64bit app. The Dynamic feature will not work otherwise.

  14. #12
    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: why do icons only show up on my computer ??

    Quote Originally Posted by masher View Post
    Dynamic dependencies are found by running a Static detection and then using the "Profile" pulldown menu and selecting "Start Profiling".

    This will show you everytime that your executable called upon qtcore4.dll AND what qtcore4 called, that is how I confirmed that I also needed to add the qico4.dll as well as the qjpeg4.dll to my VS setup project. This will actually execute your app in the process. It is a very cool feature of Dependency Walker of which I was unaware.
    I think it works the other way -- dependency walker checks which libraries are loaded by your application, not which are required by your application. To test it, add a couple of completely unrelated dll files into imageplugins directory and run the test. You'll probably see them being loaded, however they are not dependencies of your program -- it would work exactly the same way without them. Moreover, your program may not be using any JPEG files but qjpeg4.dll will still get loaded and "seen" by dependency walker, however, again, it is not a dependency of your app.
    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.


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

    masher (21st September 2012)

  16. #13
    Join Date
    Sep 2012
    Posts
    7
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: why do icons only show up on my computer ??

    Quote Originally Posted by wysota View Post
    I think it works the other way -- dependency walker checks which libraries are loaded by your application, not which are required by your application. To test it, add a couple of completely unrelated dll files into imageplugins directory and run the test. You'll probably see them being loaded, however they are not dependencies of your program -- it would work exactly the same way without them. Moreover, your program may not be using any JPEG files but qjpeg4.dll will still get loaded and "seen" by dependency walker, however, again, it is not a dependency of your app.

    I am going to have to respectfully disagree. qjpeg4.dll is dynamically called because it is needed by qtcore4.dll, which my app calls to show the .jpeg and the .ico files. If I build the .msi with qjpeg4.dll and qico4.dll removed the custom icons and the .jpgs are missing from the Qt windows.

    Kindly;
    Michael
    Last edited by masher; 20th September 2012 at 22:10. Reason: corrected .dll callouts

  17. #14
    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: why do icons only show up on my computer ??

    I don't think you are disagreeing, just confusing required with available (and loading DLLs with ultimate use of the DLL). If your application requires JPEG image handling then it requires qjpeg4.dll, no doubt. However, when Qt needs to load an image it loads all the available image format plugins (QImageIOPlugin) it can find and then asks each (QImageIOPlugin::capabilities()) whether the particular image can be handled by the plugin. It will then use the JPEG plugin in this case. (If no plugin can handle the image then built-in options are tried before failing) All of the available plugins are loaded and show in DW during a run profile.

    This code:
    Qt Code:
    1. #include <QtGui>
    2.  
    3. int main(int argc, char **argv)
    4. {
    5. QApplication app(argc, argv);
    6. QLabel l;
    7. l.setPixmap(QPixmap("Lenna.png"));
    8. l.show();
    9. return app.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 
    makes no use of JPEG, GIF etc. but because they are available DW shows:
    WinXPDev.png

    You only need to ship the plugins your applications requires but no particular harm comes from shipping them all.

  18. The following user says thank you to ChrisW67 for this useful post:

    masher (21st September 2012)

  19. #15
    Join Date
    Sep 2012
    Posts
    7
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: why do icons only show up on my computer ??

    I just ran Dependency Walker (DW) again and Profiled my .exe. It did not load any other imageformats, only the ones that it needed, which in my case is ONLY qjpeg4.dll and qico4.dll. It did not load qtiff4.dll, or qsvg4.dll, or qmng4.dll, or qgif4.dll, or qtga4.dll. It only loaded those .dll's that it depends upon.

    So, ChrisW67 & wysota, if I understand you correctly, you are saying, 'If you include ALL of the imageformat plugins into the .msi then ALL of them will be loaded at runtime, even if they are not needed.'? Okay, that helps clarify how QT works. Is that true in general for QT, or only for the (absolute ref'ed .dll) calls from qcore4.dll?

    However, going back to the initial reason for the thread.
    Re: why do icons only show up on my computer ??
    I think you will agree when I say. Obviously, I did not include the entire plugins directory in my setup project (.msi) and after I learned how to make better use of DW, it worked very well in determining which .dll's were missing from the .exe even the .dll's that were called only at runtime.

    Thanks you for really getting to the heart of the matter even though it may have been tempting to give up...

    Thanks again;
    masher

  20. #16
    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: why do icons only show up on my computer ??

    Is that true in general for QT, or only for the (absolute ref'ed .dll) calls from qcore4.dll?
    Other parts of Qt, for instance SQL support, load plugins on demand and check all the relevant plugins to see which, if any, supports the demand. Plugins provide a mechanism to extend the library without the library having to know about every possibility ahead of time. All the library knows ahead of time is the defined interfaces that a plugin must implement. It is a common idiom for extension.

  21. The following user says thank you to ChrisW67 for this useful post:

    masher (21st September 2012)

Similar Threads

  1. Show Icons in Header of QTreeView
    By blackbubblegum in forum Qt Programming
    Replies: 2
    Last Post: 11th February 2012, 01:55
  2. QMenu does not show icons from QAction
    By eumel1990 in forum Newbie
    Replies: 5
    Last Post: 10th September 2011, 11:57
  3. How to show images from database as icons in QListView
    By LeshaS in forum Qt Programming
    Replies: 2
    Last Post: 21st January 2011, 08:13
  4. QListWidget doesn't show icons
    By franco.amato in forum Qt Programming
    Replies: 8
    Last Post: 16th March 2010, 15:15
  5. how to show richtext and icons in one widget in QT2
    By pencilren in forum Qt Programming
    Replies: 1
    Last Post: 16th May 2007, 11:30

Tags for this Thread

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.