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

How to create tray icon in QtQuick application



  • The project can't pass compile when I using QSystemTrayIcon, I already include the require head file according to the Widgets app.
    There is no such problem in Widgets application.

    main.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: __thiscall QSystemTrayIcon::QSystemTrayIcon(class QObject *)" (_imp??0QSystemTrayIcon@@QAE@PAVQObject@@@Z),该符号在函数 _main 中被引用
    main.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: virtual __thiscall QSystemTrayIcon::~QSystemTrayIcon(void)" (_imp??1QSystemTrayIcon@@UAE@XZ),该符号在函数 "public: virtual void * __thiscall QSystemTrayIcon::`scalar deleting destructor'(unsigned int)" (??_GQSystemTrayIcon@@UAEPAXI@Z) 中被引用
    main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual bool __thiscall QSystemTrayIcon::event(class QEvent *)" (?event@QSystemTrayIcon@@MAE_NPAVQEvent@@@Z)
    main.obj : error LNK2001: 无法解析的外部符号 "public: virtual struct QMetaObject const * __thiscall QSystemTrayIcon::metaObject(void)const " (?metaObject@QSystemTrayIcon@@UBEPBUQMetaObject@@XZ)
    main.obj : error LNK2001: 无法解析的外部符号 "public: virtual int __thiscall QSystemTrayIcon::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@QSystemTrayIcon@@UAEHW4Call@QMetaObject@@HPAPAX@Z)
    main.obj : error LNK2001: 无法解析的外部符号 "public: virtual void * __thiscall QSystemTrayIcon::qt_metacast(char const *)" (?qt_metacast@QSystemTrayIcon@@UAEPAXPBD@Z)
    debug\untitledaaaaaaaaaaaaa.exe : fatal error LNK1120: 6 个无法解析的外部命令



  • The problem remains unresolved, there is no one try to use tray icon in quick application?



  • I found this problem only apear in QtQuick 2.0.
    In QtQuick 1.1, no errors were detective.



  • Hello and welcome to devnet,

    for me, it looks like there is an include missing or you are including the wrong header? Could you please provide us the code on how you create your tray icon?


Log in to reply