linuxdeployqt icon indicating copy to clipboard operation
linuxdeployqt copied to clipboard

icon not shown by running created AppImage

Open SiminBadri opened this issue 3 years ago • 10 comments

I've used linuxdeployqt to deploy my Qt app. It successfully creates the AppImage, however, after running the AppImage the icon of my app is not shown in the Linux menu bar.

I googled this problem and tried all the suggested solutions, however, they don't work for me.

  1. First of all, I set the icon for my app in main.cpp:

QApplication app(argc, argv); app.setWindowIcon(QIcon(":/content/icons/Play.png"));

  1. I created a folder "Play.AppDir" that has the structure like what's suggested in linuxdeployqt: Untitled1

  2. This is my Play.desktop file:

[Desktop Entry] Type=Application Name=Play Exec=Play %F Icon=Play Comment=Edit this default file Terminal=true Categories=Utility; X-AppImage-Version=1.3.2 StartupWMClass=Play Name[en_US]=Play

  1. I run the following command: $ARCH=x86_64 '/home/siminbadri/Downloads/linuxdeployqt-continuous-x86_64.AppImage' '/home/siminbadri/Documents/bin/linux/x64/Release/PlayPod.AppDir/usr/share/applications/Play.desktop' -appimage

  2. The AppImage is created successfully "Play-46b3d31-x86_64.AppImage", however, when I click on it the app Icon is not shown on the menu bar. Instead, a question mark is shown.

Untitled

Thanks

SiminBadri avatar Aug 22 '20 10:08 SiminBadri

Do you get the same behavior in e.g., KDE Plasma or Xfce?

probonopd avatar Aug 22 '20 10:08 probonopd

I tested my appImage on xubuntu but it does not show my icon

SiminBadri avatar Aug 22 '20 11:08 SiminBadri

I installed kubuntu and tested the created appImage but it did not show my icon I will try testing on kde plasma too.

Do I need to use linuxdeployqt in kde plasma to get appImage? Are the steps I mentioned before are correct and enough to get the appImage capable to show the app's icon?

SiminBadri avatar Aug 22 '20 13:08 SiminBadri

QApplication::setWindowIcon() should do the trick. In https://github.com/JvanKatwijk/qt-dab/issues/69#issuecomment-345607883 it was pointed out that

Adding setting the resources compiler in the CMakeLists.txt file did the trick

probonopd avatar Aug 23 '20 09:08 probonopd

Thank you for replying. I've added the QApplication::setWindowIcon() in my code (I also mentioned this in my first post), however, it didn't do the trick for me. I also checked the link you referenced: the icon is shown with building the app by qmake. But building with cmake needs some changes in CmakeList.txt to work. However, I build my app using qmake (by QCreator IDE). I applied all solutions suggested in forums, but still no success.

I try deploying my app on other Linux distributions to see whether it works or not. I'll inform you of the result.

Thanks

SiminBadri avatar Aug 23 '20 14:08 SiminBadri

Hi, have you tried providing the icon in different explicit resolutions (for test just copy the 256x256 PNG)? I checked against Ubuntu 16.04 (boy is that old…^^): Assuming the directory structure of an appdir/appimage is the same as on the "real" system icons are located in appdir/usr/share/icons/hicolor/scalable/apps/<my_app>.svg. This should work on most "modern" desktops. To properly provide icons for a wider variety of desktops the icon should be explicitly scaled in a bitmap format (PNG) with resolutions based on 16px -> (32x32, 48x48, 96x96, …, 256). The directory prefix may differ. Please check AppImage definitions and/or XDG.

antis81 avatar Aug 24 '20 15:08 antis81

It could also be possible that you need to tell linuxdeployqt to deploy the iconengines and imageformats plugins if they don't already get deployed. Try -extra-plugins=iconengines,imageformats.

Reference: https://github.com/probonopd/linuxdeployqt/issues/347

probonopd avatar Aug 24 '20 16:08 probonopd

I have the problem that the icon appears when running the appimage on the system where I deployed it, but not on another system (Ubuntu 22.04). Copying the image to .../256x256/apps on the destination system did not help. When I run linuxqtdeploy the image file was also in the directory where the built app is. In my main.cpp file i have a.QApplication::setWindowIcon(QIcon(":/new/prefix1/Geocalc.png")); Commands: export PATH=/home/mau/Qt/6.6.1/gcc_64/bin/:$PATH ./linuxdeployqt-continuous-x86_64.AppImage geocalc/Georechner -appimage -extra-plugins=iconengines,platformthemes/libqgtk3.so -verbose=2 deploying on Ubuntu 20.04.6 LTS

MoritzMoreira avatar Dec 10 '23 09:12 MoritzMoreira

Are you using Wayland by any chance? There the icons are utterly broken (like many things).

probonopd avatar Dec 10 '23 11:12 probonopd

both deploying and new Ubuntu are using x11, actually, at least judging from echo $XDG_SESSION_TYPE But it's working on antix (Debian 12). It's not soo important , actually...

MoritzMoreira avatar Dec 11 '23 10:12 MoritzMoreira