Greetings,
I would like to know how to access application directory in linux if I run application through shortcut. QApplication::applicationDirPath(), doesn't give right path.
Regards,
MadBear
Greetings,
I would like to know how to access application directory in linux if I run application through shortcut. QApplication::applicationDirPath(), doesn't give right path.
Regards,
MadBear
Best way may be to use argv[0].
Something like this should work under linux (not handling LONG paths though...):
Qt Code:
{ // in linux, look up the /proc/<PID>/exe link. QString link; char spath[128]; memset(spath,0,128); link.sprintf("/proc/%d/exe",getpid()); if (readlink(link.toUtf8().constData(),spath,128)>0) return spath; return ""; }To copy to clipboard, switch view to plain text mode
Last edited by bernt.ribbum; 11th March 2018 at 21:51. Reason: reformatted to look better
Bookmarks