PDA

View Full Version : Newbie asks: How to use working directory set in QtCreator



extreme001
2nd November 2010, 23:27
Hi!

I'm very new to QT and i have a question. I created a project and set the "Working directory" for debug via project settings to a path that is not the build-directory.

Is it possible to execute the code that follows so that it uses the "working directory":

QString dir;
QString styleSheet;
QString filename;
QFile styleFile;

dir = qApp->applicationDirPath();


qApp->applicationDirPath(); should point to my working directory. Is it somehow possible?

How would you deal with that? Use a build-dir and for execution a working directory?


Thank you very much!

Lykurg
3rd November 2010, 08:54
You can't alter the applications dir path. See QDir::setCurrent() instead. (Also note your wiki Current working directory)

extreme001
3rd November 2010, 10:53
OK, thank you! So...i have to find out if in debug-build and set the dir manually with

#ifdef Q_DEBUG
exedir = "C:/Mydir";
#end
#else
exedir = App->applicationDirPath();
#end

Or is their a way to set the ouput of my exe only (no other files, exe only) to a specific directory?

wysota
3rd November 2010, 17:30
What do you mean "output of my exe"? You mean the directory where the application should be built? That's controlled by the DESTDIR qmake variable.