Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use of variables like %{buildDir} in QtCreator kit settings in Qt5

In this documentation (under section "Specifying a Custom Executable to Run") I noticed that there is mention of what looks like a variable %{buildDir} in the field "Working directory".

enter image description here

I have struggled for a while now to find documentation for this feature. I would like to know first of all is there documentation for this somewhere?.

Secondary questions:

  • What other variables are available?
  • In which fields can they be used?
  • Can I access variables that I created in my project's .pro file?
  • Are there any other eval features or is this mechanism limited to variables?

Thanks!

like image 367
Lennart Rolland Avatar asked Mar 13 '16 13:03

Lennart Rolland


People also ask

How to Set environment variable in Qt Creator?

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 run Qt in terminal?

For console applications, check the Run in terminal check box. To specify the terminal to use on Linux and macOS, select Edit > Preferences > Environment > System. To run with special environment variables set up, select them in the Run Environment section. For more information, see Selecting the Run Environment.


2 Answers

As mentioned in the comments there is a "variables" button... supposedly for use all over the qt environment. However I have only found it available in obscure places that are not very useful!

However, you can at least get the list of vars from these places and use them where you actually need them. To find this, navigate to:

  • Tools (menu) --> Options --> Environment (tab) --> External Tools
  • Click "Update Translations..."
  • Click inside "Working Directory.." and you should see a "AB->" icon in colour to the right.
  • Click the icon for your list of vars.

You will notice that the style is a little different then %{BuildDir} but I believe the equivalent is %{CurrentProject:BuildPath} - You can see on the second screen shot I have right clicked and it asks you what you want to insert (the variable, or the value of the variable).

Annoyingly I could not figure out how to copy / paste the whole list as it is single line click only... maybe someone more clever can figure that out and we can stick that list in some Qt wiki :o

Here are the screen shots... Notice in screen shot 1 the little icon at the right side of "Working Directory" text-edit box.

enter image description here

enter image description here

like image 114
code_fodder Avatar answered Oct 20 '22 02:10

code_fodder


In text edit widgets within Qt Creator (v5.14.0 and possibly earlier), there is an enter image description here icon at the right end. Click on it, and a dialog of all the possibilities comes up. Make sure that the caret is at the proper position in the text edit widget.

like image 22
Richard Jessop Avatar answered Oct 20 '22 01:10

Richard Jessop