Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

qt 4.8 application launcher icon - ubuntu 14.04



  • Hi all,

    i want to use application launcher icon in my desktop app.
    i do look over this Link but unable to tackle, i feel lost somewhere. kindly suggest me correct way to do it.

    i can share demo code if you guys want


  • Moderators

    @Anas_Deshmukh said in qt 4.8 application launcher icon - ubuntu 14.04:

    i feel lost somewhere

    You need to specify where you are lost, otherwise we can't help ;-)

    My recommendations:


  • Moderators

    @Anas_Deshmukh

    This is pretty easy, just create a .desktop file for your application and install it either system wide in /usr/share/applications or for the single user in ~/.local/share/applications.

    It should look something like this:

    [Desktop Entry]
    Name=Your Application Friendly Name
    GenericName=ShortAppName
    Type=Application
    Comment=My super cool app that does cool things
    Exec=/path/to/your/app
    Icon=/path/to/your/icon.png
    

    Then let's assume your app is called, someapp and your desktop file will be someapp.dekstop, you then just do sudo cp someapp.desktop /usr/share/applications to install it system wide (notice you need root permissions for this), or cp someapp.desktop ~/.local/share/applications/ for the local user, no root required.

    I usually mix this into my installer for my application. Usually in a bash script that looks something like (note this is just a portion of my install script, use as a reference only):

    if [ -e $ddfile ] && [ ! -n $OVERWRITE ]
    then
            echo "fail, $ddfile exists, not overwriting, use ./INSTALL --overwrite"
    else
            # make .desktop file
            echo "[Desktop Entry]" > $ddfile
            echo "Name=My App" >> $ddfile
            echo "GenericName=MyApp" >> $ddfile
            echo "Type=Application" >> $ddfile
            echo "Comment=Description of MyApp" >> $ddfile
            echo "Path=$installpath/myapp" >> $ddfile
            echo "Exec=$installpath/myapp/myapp" >> $ddfile
            echo "Icon=myapp" >> $ddfile
            echo "Terminal=false" >> $ddfile
            chmod 644 $ddfile
            echo "done"
    fi
    

    My Icon in this is set just to myapp, this is because myapp.png was installed in /usr/share/pixmaps so it doesn't need the full path. Likewise you can use ~/.local/share/pixmaps if installed user specific.

    Edit: just as a warning, some window managers don't pick up these changes immediately. So if that happens where it doesn't recognize your .desktop file in the launcher right away, then just restart your wm. Gnome and KDE tend to see it right away but I can't say that for the other wms.



  • @ambershark thank you for update, i will revert you soon. i am lil busy with other task as of now. will resume this thread again.



  • @ambershark thank you for suggestion. It work smooth.


  • Lifetime Qt Champion

    Hi @Anas_Deshmukh,

    thanks for the feedback. Please mark this topic as SOLVED then.


Log in to reply