23

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!

Mr. Developerdude
  • 9,118
  • 10
  • 57
  • 95
  • In Qt Creator documentation http://doc.qt.io/qtcreator/creator-build-settings.html under "Using Qt Creator Variables" they say there must be a Variables button. But no one can see it (http://stackoverflow.com/questions/34280801/how-to-find-the-variables-button-in-qt-creator, https://forum.qt.io/topic/53252/qt-creator-variables/2). In older Qt Creator documentation there was a list with two variables only: %{buildDir} and %{sourceDir} – Evgeny S. Mar 13 '16 at 13:46
  • I guess, you can use environmet variables as ${VARNAME} in Qt Creator. An advantage is that you can use the same variables in your .pro files, so you will get access to some global settings that can be used both in Qt Creator project tab and in .pro files. – Evgeny S. Mar 13 '16 at 13:52
  • 1
    I asked the [**exactly** same question 3 months ago](http://stackoverflow.com/q/34271859/607407). Even the title is almost the same. How come it didn't pop up in your search results? – Tomáš Zato Mar 14 '16 at 09:56
  • I am sorry, i missed that. Link? And also did you get any good answers? – Mr. Developerdude Mar 14 '16 at 13:39
  • @LennartRolland The link is in my previous comment, here it is again: http://stackoverflow.com/q/34271859/607407 – Tomáš Zato Mar 14 '16 at 14:41

2 Answers2

35

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

code_fodder
  • 15,263
  • 17
  • 90
  • 167
  • 4
    This is a good start, but it still doesn't show the complete list - e.g., you won't find `Qt:Version` here. For the curious, you can clone/download Qt Creator's source from GitHub, and then grep the `src` directory for `registerVariable(`. You still won't get the complete list, since it won't include variables registered by plugins, but it's the most complete I've found. – PCaetano Apr 24 '19 at 10:58
5

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.

Richard Jessop
  • 897
  • 1
  • 12
  • 19
  • 1
    Great, that was hard to notice until you mentioned :D. Also note that a summary of the what the variable represents, and its current value can be seen at the bottom of the dialog box (as can be seen from the screenshots in @code_fodder's answer) – Jeromy Adofo Apr 18 '21 at 09:14