How to get current working directory path of a Qt application?

Your application cannot know where the project is, because this is a qt-creator option. If you want to run your binary in the project path you have to setup your working directory inside qt-creator to the correct path. Then QDir::currentPath() will return the path you want to have.

goto: projects->[environment]->run->working directory


Checkout QCoreApplication::applicationDirPath(), it tries to figure out the directory the executable is in, rather than checking the current working directory

Tags:

C++

Qt