问题
I

I have tried to do this using .desktop file by setting Icon = myPath/icon.icon or icon.PNG But it does not work. Any idea of how to do this ?
回答1:
This question isn't really Qt related.
In Linux, icons are set in the .desktop file in /usr/share/applications/
and not on the executable itself. 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
:
[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)
来源:https://stackoverflow.com/questions/41690822/how-to-set-executable-application-icon-in-linux-based-qt