I need to get the path to the application dir or the executable.
I found that
QString appPath = QCoreApplication::applicationDirPath();
would be the way to do it.
But when I run, I get error:
QCoreApplication::applicationDirPath: Please instantiate the QCoreApplication object first
If i try to create an instance of QCoreApplication though i get build errors...
error: no matching function for call to 'QCoreApplication::QCoreApplication()'
Using QApplication instead of QCoreApplication gives me a similar error.
This call is not made from main() that instantiates an application type class... it is from a config class very far away.
How is this done ?
Qt 4.8
Note: what I am trying to get is the actual app directory (for mac, i will use it to generate an absolute path to Contents/Resources).
Using a relative path did not work (I got a funny @ symbol when I printed the path, before the relative path portion, and the file I tried to load from there failed to load)
@/myapplication.app/Contents/Resources/myfile
instead of
path/myapplication.app/Contents/Resources/myfile