QtCreater增加自动添加注释的快捷代码

简介: QtCreater增加自动添加注释的快捷代码

在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}

目录
相关文章
【QT】创建、打开QT项目只显示.pro文件的问题解决
【QT】创建、打开QT项目只显示.pro文件的问题解决
4849 0
|
开发工具 Windows
关于 fatal error LNK1158: 无法运行“rc.exe” 的解决方法
关于 fatal error LNK1158: 无法运行“rc.exe” 的解决方法
关于 fatal error LNK1158: 无法运行“rc.exe” 的解决方法
|
Web App开发 存储 Linux
Linux(33)Rockchip RK3568 Ubuntu22.04上通过SSH运行Qt程序和关闭Chrome的密钥提示
Linux(33)Rockchip RK3568 Ubuntu22.04上通过SSH运行Qt程序和关闭Chrome的密钥提示
2274 0
|
编译器 Linux C语言
QT编译安装QtMqtt子模块,WIN平台
QT编译安装QtMqtt子模块,WIN平台
1231 0
|
数据可视化
【Qt 学习笔记】Qt窗口 | 菜单栏 | QMenuBar的使用及说明
【Qt 学习笔记】Qt窗口 | 菜单栏 | QMenuBar的使用及说明
5124 3
|
数据可视化 开发工具 C++
Qt Creator 界面
Qt Creator 界面
【Qt 学习笔记】Qt窗口 | 标准对话框 | 输入对话框QInputDialog
【Qt 学习笔记】Qt窗口 | 标准对话框 | 输入对话框QInputDialog
1905 3
|
Windows
解决windows下Qt Creator显示界面过大的问题
解决windows下Qt Creator显示界面过大的问题
【Qt 学习笔记】Qt常用控件 | 布局管理器 | 网格布局Grid Layout
【Qt 学习笔记】Qt常用控件 | 布局管理器 | 网格布局Grid Layout
4052 2