¿Variable que se refiere al directorio del proyecto en 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)?

preguntado el 24 de agosto de 12 a las 10:08

4 Respuestas

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

%{buildDir} también está disponible.

Respondido 27 ago 12, 06:08

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

Además de nuestras localidaded en %{sourceDir} y %{buildDir}, podrías usar %{CurrentDocument:Path}, %{CurrentDocument:FilePath} y %{CurrentProject:Path} to refer to specific files and folders in the project directory.

Respondido 18 Jul 14, 07:07

Can anyone tell me where the documentation for these variables are? Is it just in the drop down or anywhere in the manual? - steventaitinger

El incorporado _PRO_FILE_PWD_ variable contains the path to the directory containing the project file in use. That variable may be useful for you.

Respondido el 15 de diciembre de 14 a las 15:12

There are problems with $$_PRO_FILE_PWD_ on windows, because it contains forward slash allways. You need to fix slash using shell_path.


contestado el 07 de mayo de 14 a las 13:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.