PDA

View Full Version : get .pro directory



Alnitak
14th October 2010, 13:12
I would like to get the path of the main .pro file. The problem is that I use shadow build so isn't the same dir and can't use QDir::currDir().
Maybe $$_PRO_FILE_PWD_ should do the trick, but how ?
I tried putting this in .pro

debug {
DEFINES += DEBUGGING
DEFINES += "PWD_PRO=$$_PRO_FILE_PWD_"
}

how to read PWD_PRO ? if I do
qDebug() << PWD_PRO;

PWD_PRO is expanded right to directory tree, but the compiler gives errors
There is some method to do this ?

thanks in advance

high_flyer
14th October 2010, 13:41
but the compiler gives errors
it will help if you can post the errors.

Alnitak
14th October 2010, 13:47
thanks for quick replay

this is the code in cpp


#ifdef Q_WS_X11
#ifdef DEBUGGING
qDebug() << PWD_PRO;
#else
...
#endif
#endif


compiling this gives:
../MediaDownloader/main/styles.cpp:41:17: error: expected primary-expression before ‘/’ token
../MediaDownloader/main/styles.cpp:41:17: error: ‘home’ was not declared in this scope
../MediaDownloader/main/styles.cpp:41:17: error: ‘deimos’ was not declared in this scope
../MediaDownloader/main/styles.cpp:41:17: error: ‘Lavori’ was not declared in this scope
../MediaDownloader/main/styles.cpp:41:17: error: ‘workspace’ was not declared in this scope
../MediaDownloader/main/styles.cpp:41:17: error: ‘MediaDownloader’ was not declared in this scope

that are actualy the path

thanks again

high_flyer
14th October 2010, 14:00
Can you show few (code) lines before and after the line of the first error?

Alnitak
14th October 2010, 17:35
sure:


QFileInfoList styles::getCssFileList()
{
#ifdef Q_WS_X11
#ifdef DEBUGGING
qDebug() << PWD_PRO;
// CSSpath.setPath(QDir::currentPath()+"/css/");
#else
CSSpath.set Path(QDir::homePath()+"/.mediadownloader/");
#endif
#endif


#ifdef Q_WS_WIN
CSSpath.setPath(QDir::currentPath()+"/css/");
#endif

if (!CSSpath.exists()) CSSpath.mkdir(CSSpath.absolutePath());

CSSpath=CSSpath.toNativeSeparators(CSSpath.absolut ePath());
return CSSpath.entryInfoList(QStringList("*.css"),QDir::Files,QDir::Name);
}


the function is declared static, but even if I put the qDebug() into constructor it gives error

Alnitak
14th October 2010, 18:43
actually I managed this with "#" directive, but my brain can't reach this :mad:



#define QUOTEME_(x) #x
#define QUOTEME(x) QUOTEME_(x)


then doing


qDebug() << QUOTEME(PWD_PRO);

will exand as I want

sorry was a c++ related topic not Qt