简体   繁体   English

托盘中的c ++图标

[英]c++ icon in tray

i used qt to make an application in the tray. 我用qt在托盘中制作了一个应用程序。 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. 在我的PC上,这是一个很好的项目,我在托盘栏中看到了该图标,但是当我释放它以将其提供给其他人时,他们看不到该图标,它只是一个可以使用的看不见的正方形,但没有显示该图标。 but on my pc it shows the icon. 但是在我的电脑上却显示了该图标。 :S i know it sounds weird but does anybody know how to solve it? :S我知道这听起来很奇怪,但是有人知道如何解决吗? 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 . 看看Qt资源文档 Basically, you just need to create a resource file, add the icon and then change the filename to something like this ":/favicon.ico". 基本上,您只需要创建一个资源文件,添加图标,然后将文件名更改为“:/favicon.ico”即可。 By adding the ":/" in front of the filename, Qt knows to load this from the embedded resources. 通过在文件名前面添加“:/”,Qt知道可以从嵌入式资源中加载它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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