Qt App Icon will only show on certain PCs



  • Hello!

    I use QT 5.2.1 with QtMSVCAddin 5.2.1
    (I only use the ui designer from Qt, the rest is done in MSVC 2012)
    and have a Problem with displaying an Application Icon on some PCs.

    I set the icon resources in MSVC as usual with an rc file:
    "IDI_ICON1 ICON DISCARDABLE "icon1.ico""
    With this, the .exe file (in explorer) will show the icon correctly on every tested PC.
    BUT: The icon next to the appliccation-title and also the icon in the taskbar is still the default icon.

    So somehow the qt stuff overwrites my icon which was set in the rc file.
    Why, and where can i fix it?

    furthermore i added the same icon through the ui designer from qt.
    and somewhere in the genereated sourcecode this lines show up:
    QIcon icon;
    icon.addFile(QStringLiteral("icon1.ico"), QSize(), QIcon::Normal, QIcon::On);
    this->setWindowIcon(icon);
    The funny part is. with this lines, only systems with Qt installed can display the icon (in title and bar)
    Also the icon1.ico file must be beside the .exe file, which is pretty ugly.

    anyway to help me?
    i cant be the only one with this Problem =(


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    You can use Qt's resource system to embbed the icon within your application. Also, did you check that you deployed all the required imageformat plugins with your application ?

    On what version of windows does it happen ?



  • How would i insert the icon to the Qt's resource system?

    Is there a dll i have to place beside the .exe for icon Applications?

    Every testet System is win7.
    The Software does not need to be downwards compatible.



  • I found out how to add and use .qrc files with qt Projects, and learnt that my Qt does not seam to work right.

    Because somehow my res.qrc never get compiled by the rcc.exe.
    No Files where created in any way.

    This is my .pro:
    @
    #-------------------------------------------------

    Project created by QtCreator 2015-02-25T16:00:14

    #-------------------------------------------------

    QT += core gui

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = qtico
    TEMPLATE = app

    SOURCES += main.cpp
    qtico.cpp

    HEADERS += qtico.h

    FORMS += qtico.ui

    RESOURCES +=
    res.qrc
    @
    ###########################################

    This is my res.qrc File:
    @
    <RCC>
    <qresource prefix="/">
    <file>logo.png</file>
    <file>icon.ico</file>
    </qresource>
    </RCC>
    @
    #########################################

    This is the code which should load the logo from the ressource:
    (This time no Icon. But if i Fix this problem i may fix the Icon problem)
    @
    QImage image("qrc:/logo.png");
    if(!image.isNull()) {
    ui->label->setPixmap(QPixmap::fromImage(image));
    ui->label->show();
    }
    @

    [edit: added missing coding tags @ SGaist]


  • Lifetime Qt Champion

    IIRC you should not put qrc in front of your resource path only :/



  • Tried it with, without and a thousand other ways i found in some forums.
    Non of them works.

    But lets stick to the Problem.
    What should happen to a .qrc file?
    No file where generated when i run the program except other stuff.
    I dont even try to do it with MSVC. its a pure new Qtonly app.
    And i cant figure out how to get ressources work.



    1. Create the rc file with below content in the same path

    @IDI_ICON1 ICON DISCARDABLE "icon1.ico"@

    1. Insert the rc file into the project file

    @win32:RC_FILE += abc.rc@

    1. Clean the project and run.

Log in to reply
 

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