简体   繁体   English

如何在基于Linux的Qt中设置可执行文件(应用程序)图标

[英]How to set executable (application) icon in Linux based Qt

I 一世 Linux中可执行文件的默认图标 I want to change this default icon to my desired icon. 我想将此默认图标更改为所需的图标。 How to do this ? 这个怎么做 ? I have searched and found solution for Windows How to set application icon in a Qt-based project? 我搜索并找到了Windows解决方案如何在基于Qt的项目中设置应用程序图标? but not for Linux. 但不适用于Linux。

I have tried to do this using .desktop file by setting Icon = myPath/icon.icon or icon.PNG But it does not work. 我尝试通过设置Icon = myPath / icon.icon或icon.PNG使用.desktop文件来执行此操作,但是它不起作用。 Any idea of how to do this ? 知道如何执行此操作吗?

This question isn't really Qt related. 这个问题与Qt无关。

In Linux, icons are set in the .desktop file in /usr/share/applications/ and not on the executable itself. 在Linux中,图标是在.desktop文件中的/usr/share/applications/而不是在可执行文件本身中设置的。 To have an icon for your app, it must be installed on your system. 要为您的应用提供图标,必须将其安装在系统上。 Place the executable in /usr/bin , your icon of choice in /usr/share/icons/hicolor/ and put a .desktop file that corresponds to your application in /usr/share/applications : 将可执行文件放在/usr/bin ,将选择的图标放在/usr/share/icons/hicolor/ ,并将与您的应用程序相对应的.desktop文件放在/usr/share/applications

[Desktop Entry]
Type=Application
Version=1.0
Name=(insert name of app)
GenericName=("Web Browser", "Media Player", etc. This isn't technically needed but makes your app look native on KDE)
Exec=(insert executable name)
Icon=(insert icon name)

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

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