[Solved] QIcons are not shown in binary, while shown when compiled from source



  • I have a big Qt program which is compiled using CMake. I add the resource files by
    qt5_add_resources(IMG_RSC_ADDED Data/Actions.qrc )
    add_executable(${PROJECT_NAME} ${Application_SRCS} ${IMG_RSC_ADDED} )

    In my program, I load these icons to actions, for example:

    m_action = new QAction(":/icon.svg", tr("&Bar"), this);

    And everything works when I compile from source - the icons are where they are supposed to be.

    I created a binary of my program so that to test it on another machine. I put all the necessary dlls to the folder where my exe file is. However, the icons are not displayed in that binary. While I thought that the command qt5_add_resources makes the icons a part of the binary, it does not seem to be the case. Where my problem could be? How to make the icons to be displayed in the binary?


  • Lifetime Qt Champion

    Hi,

    Maybe a silly question but do you have the SVG plugin deployed ?



  • Hi, thank you for suggestion, but yes, I have all the necessary plugins.



  • Hi, to add to @SGaist's thinking (plugin problem) what happens if you try a Windows .bmp file instead of a .svg file?



  • @hskoglund , thank you for suggestion.

    I tried few things, and I also tried other file formats like png. It started to work after I added Q_INIT_RESOURCE macro, but only for png format. Does it mean I am missing some plugins to add support for svg?

    Inside my binary folder, I already have imageformats and iconengines. I can see that both contain dlls related to svg format: imageformats has qsvg.dll and iconengines has qsvgicon.dll. Any ideas why svg cannot be displayed in binary? Thanks!



  • Hi, it could be a simple answer: maybe you forgot to copy Qt5Svg.dll to your other machine?



  • @hskoglund You were right! Thank you.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.