简体   繁体   中英

c++ icon in tray

i used qt to make an application in the tray. on my pc its a good project and i see the icon in the traybar, but when i release it to give it to sombody else they dont see the icon, its just an invissible square that can be used but it dont show the icon. but on my pc it shows the icon. :S i know it sounds weird but does anybody know how to solve it? or how to set the traybar icon in the resource file?

this->setWindowIcon(QIcon("favicon.ico"));
a.start();
createActions();
createTrayIcon();
trayIcon->setIcon(QIcon("favicon.ico"));
trayIcon->setVisible(true);
trayIcon->show();

Well, I assume that you forgot to provide the icon together with the executable. But in any case, it would be better to embed the icon as resource in the executable. Have a look at the Qt resource documentation . Basically, you just need to create a resource file, add the icon and then change the filename to something like this ":/favicon.ico". By adding the ":/" in front of the filename, Qt knows to load this from the embedded resources.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM