Solution 1:

Setting the icon in your .desktop file is adding it to your application configuration, so I'm not quite sure what you're asking. As long as the icon is installed with everything else, you should be all set. If you're installing via a click package, a relative file name for the icon in the .desktop file is all you need; otherwise, you may want to use an absolute path.

If you're trying to get the icon set for a program that isn't installed, you can add the desktop file to ~/.local/share/applications/. IIRC, this file won't be immediately detected, but it will be loaded eventually. Logging out and then back in will probably force a refresh.

If you want to adjust the icon programmatically while the application is running, I can't help you. I'd be surprised if you could do that through pure QML, but it might be easy to write a C++ plugin.