'application cannot get the running AppImage path

In my application, sometimes I need to find out the path of the application executable. I use QApplication::applicationFilePath() and it works fine. But when I distribute my application as AppImage on Linux, this breaks. It returns the path where the running AppImage was mounted, e.g. /tmp/.mount_MyAppxyzabc/MyApp. But I would need to get the path of the AppImage itself, e.g. /home/vlad/MyApp/MyApp.AppImage. Is this possible to obtain from inside the running application?



Solution 1:[1]

The code above doesn't work for me. appImagePath is set to an empty QString. Also, the following:

QProcessEnvironment env(QProcessEnvironment::systemEnvironment());
QStringList tt = env.keys();
QFile outFile("./debug.txt");
outFile.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream out(&outFile);
for (QStringList::iterator it = tt.begin(); it != tt.end(); ++it)
    out << *it << " " << env.value(*it) << endl;
outFile.close();

works for me in my release build, but doesn't in the appImage

This is on Linux.

Thanks.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Bill Cassidy