在QtCreater中,可以通过添加一些关键字来自动生成一些信息,比如注释信息;
方法如下
工具–>选项:
添加关键字以及文本:
下面的%{CurrentDate:yyyy-MM-dd}是去时间的。
设置好以后点击OK,返回试一下效果:
然后按回车,注释信息就上去了:
函数注释信息
/***************************************************************
* @function name:
* @摘要
* @输入参数
* @输出参数 无
* @返回值 void
* @author fensnote
* @date %{CurrentDate:yyyy-MM-dd}
**************************************************************/
文件头信息
如果是文件头信息的话,可以把文件名也自动提取上,如下代码:
/******************************************************************************
Copyright (C), 2017-2027, fensnote@163.com, Ltd.
******************************************************************************
File Name : %{CurrentDocument:FileName}
Version : 1.0
Author : fensnote
Created : %{CurrentDate:yyyy-MM-dd}
Last Modified :
Description : header file
Function List :
History :
1.Date : %{CurrentDate:yyyy-MM-dd}
Author : fensnote
Modification: Created file
******************************************************************************/
效果是这样的:
/******************************************************************************
Copyright (C), 2017-2027, fensnote@163.com, Ltd.
******************************************************************************
File Name : main.cpp
Version : 1.0
Author : fensnote
Created : 2022-04-13
Last Modified :
Description : header file
Function List :
History :
1.Date : 2022-04-13
Author : fensnote
Modification: Created file
******************************************************************************/
附内部变量
%{#:<value>
%{Config:DefaultProjectDirectory}
%{Config:LastFileDialogDirectory}
%{Cpp:LicenseTemplate}
%{Cpp:LicenseTemplatePath:FileBaseName}
%{Cpp:LicenseTemplatePath:FileName}
%{Cpp:LicenseTemplatePath:FilePath}
%{Cpp:LicenseTemplatePath:NativeFilePath}
%{Cpp:LicenseTemplatePath:NativePath}
%{Cpp:LicenseTemplatePath:Path}
%{CurrentBuild:Env:<value>}
%{CurrentBuild:Name}
%{CurrentBuild:Type}
%{CurrentDate:<value>}
%{CurrentDate:ISO}
%{CurrentDate:Locale}
%{CurrentDate:RFC}
%{CurrentDevice:HostAddress}
%{CurrentDevice:PrivateKeyFile}
%{CurrentDevice:SshPort}
%{CurrentDevice:UserName}
%{CurrentDocument:Column}
%{CurrentDocument:ColumnCount}
%{CurrentDocument:FileBaseName}
%{CurrentDocument:FileName}
%{CurrentDocument:FilePath}
%{CurrentDocument:FontSize}
%{CurrentDocument:NativeFilePath}
%{CurrentDocument:NativePath}
%{CurrentDocument:Path}
%{CurrentDocument:Row}
%{CurrentDocument:RowCount}
%{CurrentDocument:Selection}
%{CurrentDocument:XPos}
%{CurrentDocument:YPos}
%{CurrentKit:FileSystemName}
%{CurrentKit:Id}
%{CurrentKit:Name}
%{CurrentProject:BuildPath}
%{CurrentProject:FileBaseName}
%{CurrentProject:FileName}
%{CurrentProject:FilePath}
%{CurrentProject:Name}
%{CurrentProject:NativeFilePath}
%{CurrentProject:NativePath}
%{CurrentProject:Path}
%{CurrentProject:QT_HOST_BINS}
%{CurrentProject:VcsName}
%{CurrentProject:VcsTopLevelPath}
%{CurrentProject:VcsTopic}
%{CurrentRun:Executable:FileBaseName}
%{CurrentRun:Executable:FileName}
%{CurrentRun:Executable:FilePath}
%{CurrentRun:Executable:NativeFilePath}
%{CurrentRun:Executable:NativePath}
%{CurrentRun:Executable:Path}
%{CurrentRun:Name}
%{CurrentTime:<value>}
%{CurrentTime:ISO}
%{CurrentTime:Locale}
%{CurrentTime:RFC}
%{Env:<value>}
%{HostOs:ExecutableSuffix}
%{HostOs:PathListSeparator}
%{HostOs:isLinux}
%{HostOs:isOSX}
%{HostOs:isUnix}
%{HostOs:isWindows}
%{IDE:ResourcePath}
%{JS:<value>}
%{Session:FileBaseName}
%{Session:FileName}
%{Session:FilePath}
%{Session:Name}
%{Session:NativeFilePath}
%{Session:NativePath}
%{Session:Path}
%{UUID}
欢迎关注微信公众号: