Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt Creator placeholders

Tags:

c++

qt

qt-creator

I found out that Qt Creator can insert a license template header when creating a new file and fill certain placeholders automatically like file name and year:

/**
  @file   %FILENAME%
  Copyright (c) %YEAR%
*/

Are these placeholders documented anywhere ? Maybe in some kind of a list ?

PS: Under this bug report (QTCREATORBUG-14726) Tobias Hunger commented that a new macro style of this format: %{CurrentDate:FORMATSTRING} is being used. But I can't find a documentation for this either!

like image 905
luffy Avatar asked Jan 13 '16 09:01

luffy


2 Answers

I can't see anything where there is a license file already stored, but on Qt website it says this:

Adding a License Header Template for C++ Code

A file containing a license header for C++ can be specified under Tools > Options > C++ > License Template. It may contain special placeholders enclosed in %% that are replaced when generating a new file:

%YEAR%: Year
%MONTH%: Month
%DAY%: Day of the month
%DATE%: Date
%USER%: Username
%FILENAME%: File name
%CLASS%: Class name (if applicable)
%$VARIABLE%: Contents of environment variable VARIABLE.

which can be set in:

Tools->Options...->C++->File Naming
like image 82
GPPK Avatar answered Nov 04 '22 03:11

GPPK


After some digging around the issue mention in the OP the following seems to work with QtCreator 4.2.0:

%{Cpp:License:FileName}
%{Env:<Environmentalvar>} E.g: %{Env:PATH}
%{CurrentDate:yyyy-MM-dd}
%{Cpp:License:ClassName}

From the QtCreator Sources. It would be nice to get this properly documented.

like image 28
CJCombrink Avatar answered Nov 04 '22 03:11

CJCombrink