How can we get the current working directory path ?
-
wrote on 14 Mar 2012, 06:19 last edited by
I have tried
@QDir::currentpath()@
but here i am getting the path of current application directory. I want to get path of current working project. -
wrote on 14 Mar 2012, 06:37 last edited by
Please define "current working project", I don't know what you mean.
-
wrote on 14 Mar 2012, 07:28 last edited by
[quote author="Scylla" date="1331707050"]Please define "current working project", I don't know what you mean.[/quote]
Suppose the project i am currently running under Qt is "mainwindow". The mainwindow project is present in path "C:/Documents and setting/ Desktop / mainwindow". So i want to get this path.While i am using QDir::currentpath() i am getting "C:/Documents and setting/ Desktop /mainwindow/mainwindow.app/Contents/MacOS" as current path in MAC for that project. which is actually the application path not the current project path. So how could i get the only project path?
-
wrote on 14 Mar 2012, 07:36 last edited by
I don't think this is possible without passing any additional information, as the resulting binary has no information about the origin project structure.
@
// .proDEFINES += PROJECT_PATH="\"$$PWD\""
DEFINES += BUILD_PATH="\"$$OUT_PWD\""// .cpp
QString projectPath(PROJECT_PATH);
QString buildPath(BUILD_PATH);
@ -
wrote on 14 Mar 2012, 08:25 last edited by
[quote author="Lukas Geyer" date="1331710589"]I don't think this is possible without passing any additional information, as the resulting binary has no information about the origin project structure.
@
// .proDEFINES += PROJECT_PATH="\"$$PWD\""
DEFINES += BUILD_PATH="\"$$OUT_PWD\""// .cpp
QString projectPath(PROJECT_PATH);
QString buildPath(BUILD_PATH);
@[/quote]
thanks, this i was trying to get. -
wrote on 15 Mar 2012, 08:50 last edited by
Note that this is then hard coded into your binairy at compile time. Not sure if that is what you expect when you distribute your application...
3/6