Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Variable that refers to the project directory in Qt Creator?

I'm working on a cross-platform Qt application and the paths are different on Mac OS X and Windows. Since the project is on an external hard-drive, the drive letter also occasionally changes on Windows.

For that reason, I would like to refer to the project directory using a variable, preferably a built-in one. In particular, is there such a variable usable in:

  • The .pro file?
  • The build settings (in the Projects tab)?
like image 633
laurent Avatar asked Aug 24 '12 09:08

laurent


People also ask

What is $$ PWD in Qt?

$$PWD means the dir where the current file (. pro or . pri) is. It means the same in LIBS . I just used it like this in my project: LIBS += -L$$PWD/deps/android -lopenal.

How do I set environment variables in Qt?

You can edit existing environment variables or add, reset and unset new variables based on your project requirements. To globally change the system environment from the one in which Qt Creator is started, select Edit > Preferences > Environment > System, and then select Change in the Environment field.

How do I open a QT project folder?

In the Qt Creator application, choose menu File->Open File or Project, navigate to the project folder and choose the . pro file to open.

What is Qt project file?

A .pro file is actually the project file used by qmake to build your application, library, or plugin. It contains all the information, such as links to the headers and source files, libraries required by the project, custom-build processes for different platforms/environments, and so on.


2 Answers

To complete, @Bill's answer, the way to refer to the source path in the Build Settings is to use %{sourceDir}.

%{buildDir} is also available.

like image 65
laurent Avatar answered Sep 28 '22 00:09

laurent


Since I struggled a bit to find it, I'm adding it here.

In addition to %{sourceDir} and %{buildDir}, you could use %{CurrentDocument:Path}, %{CurrentDocument:FilePath} and %{CurrentProject:Path} to refer to specific files and folders in the project directory.

like image 26
Allakazam Avatar answered Sep 27 '22 23:09

Allakazam