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

[Solved] SysTray svg icon missing on Windows 7



  • I am writing a small program - the SysTray svg icon is visible on Ubuntu (though in a wrong place), but completely missing - just an empty space - on Windows 7 (though the context menu is available when right-clicking on this empty space).

    At runtime there are two error lines in the application console:

    Cannot open file ':/dch.svg', because: Unknown error
    Cannot open file ':/dch.svg', because: Unknown error

    at this string of loading the icon:

    QIcon *SysTrayIcon = new QIcon(":/dch.svg");

    It is Windows 7 32-bit, Qt 5.2.1, MinGW48-32

    All the libraries are written in .pro file and made available in the build folder and sub-folders "platforms" and "plugins". When opening the .qrc file in QtCreator, the icon is perfectly displayed.

    Have tried to change the slash to backslash, to put the icon in build folder, not in /res, another folder up, root folder - no way.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    IIRC you would need the QtSvg module to load svg files.

    On a side note, you shouldn't need to allocate a QIcon on the heap. You are probably creating a memory leak here



  • Qt5Svg is and was here all the time with no success...

    Thank you for the side note - I am new to C++, just learning :)

    @ QIcon SysTrayIcon;
    SysTrayIcon.addFile(":/dch.svg");
    @

    But the icon still missing...



  • Problem solved removing the language from ,qrc file



  • Hi,

    Please add [solved] to the title of your first post to inform others


  • Lifetime Qt Champion

    Out of curiosity, what do you mean by removing the language from the qrc file ?



  • @<RCC>
    <qresource lang="en" prefix="/">
    @

    My Windows 7 is russian, so now I think specifying lang="en" wasn't exactly smart :) but Im just learning...


  • Lifetime Qt Champion

    Thanks for the reminder, I've forgot that technique :)


Log in to reply