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

[solved]Invisible system tray icon



  • I created tray icon:

    LogWindow::LogWindow(QWidget *parent)
    : QMainWindow(parent)
    {
    ...
    createTrayIcon();
    trayIcon->show();
    ...
    }

    void LogWindow::createTrayIcon()
    {
    trayIcon = new QSystemTrayIcon(this);
    QIcon icon("/Resources/trayIcon.png");
    trayIcon->setIcon(icon);
    }

    But in tray it's invisible, only empty place, and instead of one, appears two 'icons\empty places' and if add events to show\hide window and click each empty place - appears two different windows and I can write different text in each.
    I read something about creating .qrc file and adding 'icon' prefix and file, but I use visual studio qt addin and don't know what I shoulde do there.


  • Lifetime Qt Champion

    Hi,

    It's because your path is absolute thus at run time it tries to find the file in C:/Resources/tryIcon.png. Here you have an explanation on how to handle resource with the Qt Addin.

    Hope it helps



  • @SGaist
    Finally i solved the problem. I just created usual notepad file, then renamed it to .qrc file and in VS it opened without any problems


Log in to reply