Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

No picture in system tray



  • Hey you,

    I try to implement a System Tray Icon in my application

    After using the search and several tutorials I already have an Icon, but without any kind of picture. The Icon in the bar is empty.

    I am using the following code in the resource file:

    @<RCC>
    <qresource prefix="/images“>
    <file>favicon.ico</file>
    </qresource>
    </RCC>@

    The file is saved in my project directionally where the other files are saved.

    I included the resource file via my .pro file,

    @RESOURCES += res.qrc@

    The creation of the System Tray Icon is in the constructor

    @trayIcon = new QSystemTrayIcon(this);
    trayIcon->setIcon(QIcon(QPixmap(":/images/favicon.ico")));
    trayIcon->show();@

    As said the icon in already in the bar in the corner of the desktop, but without the picture (favicon.ico).

    Do you have any idea?

    Thank you very much in advance for your help!

    Cheers


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    You should add some check to ensure your image is found and loads.

    Also what OS/Qt combo are you using ?


Log in to reply