Problem with application icon



  • Hi all,

    I've developped an application with Qt Creator 2.4.1 (particularly, with Qt 4.8.1 for Desktop - MinGW (Qt SDK)). This app has an icon that I've assigned to the main window. When I run the app in debug mode, the icon in the main window appears normally:

    0_1523734700284_DebugRun.png

    but when I run the release version, it doesn't:

    0_1523734725284_ReleaseRun.png

    Can you please tell me what I am doing wrong? I've assigned the icon to the main window from a qrc file, like this:

    0_1523734835066_MainWindow_IconSelection.png

    This is the contents of the qrc file:

    <RCC>
        <qresource prefix="/">
            <file>VFIT-red.ico</file>
        </qresource>
    </RCC>
    

    And this is the contents of the pro file:

    #-------------------------------------------------
    #
    # Project created by QtCreator 2017-10-28T22:20:02
    #
    #-------------------------------------------------
    
    QT       += core gui xml network
    
    TARGET = VFIT
    TEMPLATE = app
    RC_FILE = VFIT.rc
    
    SOURCES += main.cpp\
            mainwindow.cpp \
        designselector.cpp \
        viewlistclassificator.cpp \
        RandGenParList.cpp \
        RandGenPar.cpp \
        FaultModelParList.cpp \
        FaultModelPar.cpp \
        InjectionConfiguration.cpp \
        TargetParList.cpp \
        TargetPar.cpp \
        RangePar.cpp \
        RangeParList.cpp \
        ViewListParList.cpp \
        ViewListPar.cpp \
        TcpClient.cpp
    
    HEADERS  += mainwindow.h \
        designselector.h \
        viewlistclassificator.h \
        BasicDeclarations.h \
        RandGenParList.h \
        RandGenPar.h \
        FaultModelParList.h \
        FaultModelPar.h \
        InjectionConfiguration.h \
        TargetParList.h \
        TargetPar.h \
        RangePar.h \
        RangeParList.h \
        ViewListParList.h \
        ViewListPar.h \
        TcpClient.h
    
    FORMS    += mainwindow.ui \
        designselector.ui \
        viewlistclassificator.ui \
        TcpClient.ui
    
    RESOURCES += \
        VFIT.qrc
    
    

    I know this is a minor problem, but it's making me crazy. I've tried even copying the icon file in the same path as the exe (just in the same way as with the dlls to be able to run the exe).

    Anyway, I'd like to know if it is due to a programming mistake.

    Thanks in advance,


  • Lifetime Qt Champion

    Hi,

    Pretty strange. Can you do a quick check ? Print a debug message with the return value of QFile::exists on the path to your icon file. It should return true both time.



  • The ico image format is provided via a plugin in Qt4 and Qt5 so I guess the release version of this plugin is not found / shipped with the application.



  • This post is deleted!


  • This post is deleted!


  • @SGaist said in Problem with application icon:

    Hi,

    Pretty strange. Can you do a quick check ? Print a debug message with the return value of QFile::exists on the path to your icon file. It should return true both time.

    Hi @SGaist,

    Thank you for your quick answer. I've tried asking for the existence ico file, as you suggested, and it was found in both cases. Then, with this same idea, I've asked for the name of the MainWindow icon (at the very beginning of the constructor):

    qDebug() << "this->windowIcon().name()" << this->windowIcon().name();
    

    and, surprisingly, the answer has been "" in both cases, even though in debug mode the icon actually appeared!

    I'm really shocked...



  • @Christian-Ehrlicher said in Problem with application icon:

    The ico image format is provided via a plugin in Qt4 and Qt5 so I guess the release version of this plugin is not found / shipped with the application.

    Hi @Christian-Ehrlicher,

    Thanks you a lot for your quick answer.

    And how could I ship it? Copying all the Qt plugings to the application main path, and then erasing them one by one until getting what's the right one? At least, with the dlls, the proper app issues subsquent error messages indicating which dll is missing each time...



  • @JCBaraza said in Problem with application icon:

    @Christian-Ehrlicher said in Problem with application icon:

    The ico image format is provided via a plugin in Qt4 and Qt5 so I guess the release version of this plugin is not found / shipped with the application.

    Hi @Christian-Ehrlicher,

    Thanks you a lot for your quick answer.

    And how could I ship it? Copying all the Qt plugings to the application main path, and then erasing them one by one until getting what's the right one? At least, with the dlls, the proper app issues subsquent error messages indicating which dll is missing each time...

    Hi again,

    As the application icon is a 16x16 ico file, I've tried copying one by one the "qico*.dll" files (well, not all actually; I've tried only the "qico4.dll" and "qicod4.dll" files in "Desktop\Qt\4.8.1\mingw\plugins\imageformats", "Desktop\Qt\4.7.4\mingw\plugins\imageformats", "Simulator\Qt\mingw\plugins\imageformats", "Simulator\Application\plugins\imageformats" and "QtCreator\bin\imageformats" folders). But I'm affraid that nothing has changed. The icon is still missing in the min window.

    Should I try other plugins? Any other suggestions, please?



  • You have to make sure to ship the correct plugin which fits to your version of the shipped Qt dlls. Also they should reside under <appdir>\plugins\type. See http://doc.qt.io/archives/qt-4.8/deployment-plugins.html (chapter 'The Plugin Directory' - the rest is not needed in your case) for more information



  • @Christian-Ehrlicher said in Problem with application icon:

    You have to make sure to ship the correct plugin which fits to your version of the shipped Qt dlls. Also they should reside under <appdir>\plugins\type. See http://doc.qt.io/archives/qt-4.8/deployment-plugins.html (chapter 'The Plugin Directory' - the rest is not needed in your case) for more information

    Hi Christian-Ehrlicher,

    Wow! It's been hard to understand so much information about application deployment, but I finally got it. Thank you so much.

    Once you know that you have to generate a folder in your application path (or wherever else, actually) to copy the required plugins, it's just a "simple" brute force task. I've seen that this is a recurrent problem, so I include the "algorithm" in case it's useful for someone in the future:
    1.- Copy all the plugin subfolders hanging from "your" particular Qt plugins folder (in my case, "Desktop\Qt\4.8.1\mingw\plugins").
    2.- Add the local plugin path to the application path (with addLibraryPath(localPluginPath)) and build the application.
    3.- For each local plugin subfolder:
    a) Rename (for instance, starting with a "_").
    b) Run the release version of the application.
    If it works, the subfolder is not necessary => You can delete it (in my case I haven't done, just in case; I'll do when the application is completely terminated and tested).
    If it does not work, some plugin in the subfolder is required => Undo the name change.
    4.- For each non-renamed local plugin folder:
    a) For each plugin (DLL file) in the subfolder:
    i) Rename.
    ii) Run the release version of the application.
    If it works, the plugin is not necessary => You can delete it.
    If it doesn't work, the plugin is required => Undo the name change.

    Actually, I was very close yesterday: when I copied the "qico4.dll" plugin, I only needed to add the local plugin path to my application and rebuild, because finally this is the only plugin that I need so far.

    Thanks again to all.

    Best regards,


Log in to reply
 

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