PDA

View Full Version : set path with qmake and use it in the program



sajis997
12th February 2013, 02:20
Hello forum,

I want to declare a custom variable in qmake that contains the absolute path to some files. and later inside the application program i want to use the variable in qmake to get to the path and load the desired file i want to load.


Is that possible?

Any more reference example will be very helpful

Regards
Sajjad

ChrisW67
12th February 2013, 03:05
Is that possible?
Yes.

Now on to the question you really wanted to ask:


// *.pro
DEFINES += SOMEDIR=\\\"/some/full/path/\\\"

// *.cpp
QFile file(SOMEDIR "filename.ext");
// or
QDir path(SOMEDIR);
QString filePath = path.filePath("filename.ext");

Hard coding paths like this is not advisable for anything other than tests IMHO.