Qt-在QtCreator中设置片段进行快速批注或注释
资料:
https://www.jb51.net/program/303720qao.htm Qt QtCreator添加自定义注释的实现方法
https://www.cnblogs.com/xian-yongchao/p/16366955.html Qt Creator添加可以快捷键注释的自定义片段(自动联想补全)
一、QtCreator中怎么设置批注片段
在Qt中我们依次点开【工具】→【选项】→【文本编辑器】→【片段】
二、QtCreator中具有哪些功能的宏
1 自动获取当前文件名称:%{CurrentDocument:FileName} 2 自动获取当前时间:%{CurrentDate:yyyy-MM-dd} %{CurrentTime:hh:mm} 3 自动获取当前项目名称:%{CurrentProject:Name} 4 %{Config:DefaultProjectDirectory} 5 %{Config:LastFileDialogDirectory} 6 %{Cpp:LicenseTemplate} 7 %{Cpp:LicenseTemplatePath:FileBaseName} 8 %{Cpp:LicenseTemplatePath:FileName} 9 %{Cpp:LicenseTemplatePath:FilePath} 10 %{Cpp:LicenseTemplatePath:NativeFilePath} 11 %{Cpp:LicenseTemplatePath:NativePath} 12 %{Cpp:LicenseTemplatePath:Path} 13 %{CurrentBuild:Env:} 14 %{CurrentBuild:Name} 15 %{CurrentBuild:Type} 16 %{CurrentDate:} 17 %{CurrentDate:ISO} 18 %{CurrentDate:Locale} 19 %{CurrentDate:RFC} 20 %{CurrentDevice:HostAddress} 21 %{CurrentDevice:PrivateKeyFile} 22 %{CurrentDevice:SshPort} 23 %{CurrentDevice:UserName} 24 %{CurrentDocument:Column} 25 %{CurrentDocument:ColumnCount} 26 %{CurrentDocument:FileBaseName} //当前文件去掉后缀后的名称 27 %{CurrentDocument:FileName} //当前文件名 28 %{CurrentDocument:FilePath} 29 %{CurrentDocument:FontSize} 30 %{CurrentDocument:NativeFilePath} 31 %{CurrentDocument:NativePath} 32 %{CurrentDocument:Path} 33 %{CurrentDocument:Row} 34 %{CurrentDocument:RowCount} 35 %{CurrentDocument:Selection} 36 %{CurrentDocument:XPos} 37 %{CurrentDocument:YPos} 38 %{CurrentKit:FileSystemName} 39 %{CurrentKit:Id} 40 %{CurrentKit:Name} 41 %{CurrentProject:BuildPath} 42 %{CurrentProject:FileBaseName} //项目基础名称 43 %{CurrentProject:FileName} 44 %{CurrentProject:FilePath} 45 %{CurrentProject:Name} 46 %{CurrentProject:NativeFilePath} 47 %{CurrentProject:NativePath} 48 %{CurrentProject:Path} 49 %{CurrentProject:QT_HOST_BINS} 50 %{CurrentProject:VcsName} 51 %{CurrentProject:VcsTopLevelPath} 52 %{CurrentProject:VcsTopic} 53 %{CurrentRun:Executable:FileBaseName} 54 %{CurrentRun:Executable:FileName} 55 %{CurrentRun:Executable:FilePath} 56 %{CurrentRun:Executable:NativeFilePath} 57 %{CurrentRun:Executable:NativePath} 58 %{CurrentRun:Executable:Path} 59 %{CurrentRun:Name} 60 %{CurrentTime:} 61 %{CurrentTime:ISO} 62 %{CurrentTime:Locale} 63 %{CurrentTime:RFC} 64 %{Env:} 65 %{HostOs:ExecutableSuffix} 66 %{HostOs:PathListSeparator} 67 %{HostOs:isLinux} 68 %{HostOs:isOSX} 69 %{HostOs:isUnix} 70 %{HostOs:isWindows} 71 %{IDE:ResourcePath} 72 %{JS:} 73 %{Session:FileBaseName} 74 %{Session:FileName} 75 %{Session:FilePath} 76 %{Session:Name} 77 %{Session:NativeFilePath} 78 %{Session:NativePath} 79 %{Session:Path} 80 %{UUID}
三、如何查看QtCreator支持的宏
工具-》环境-》扩展工具-》更新翻译-》点击执行档中的路径(右侧显示A->B图标)-》点击AB图标-》显示当前支持的所有
四、QtCreator中片段的设置文件在哪里?
C:\Users\Administrator\AppData\Roaming\QtProject\qtcreator\snippets\snippets.xml
五、片段的实例有哪些?
1 /*! @File : %{CurrentDocument:FileName} 2 * @Brief : 简要说明 3 * @Details : 详细说明 4 * @Author : xxx 5 * @Date : %{CurrentDate:yyyy-MM-dd} 6 * @Version : v1.0 7 * @Copyright : Copyright By xxx, All Rights Reserved 8 * 9 ********************************************************** 10 * 11 * @Attention : 12 * @par 修改日志: 13 * <table> 14 * <tr><th>Date <th>Version <th>Author <th>Description 15 * <tr><td>%{CurrentDate:yyyy-MM-dd} <td>1.0 <td>xxx <td>创建初始版本 16 * </table> 17 * 18 ********************************************************** 19 */ 20 21 /*! 22 @Function : Name 23 @Description : 详细描述 24 @Author : xxx 25 @Parameter : 参数说明 26 @Return : 返回值说明 27 @Output : 28 @Date : %{CurrentDate:yyyy-MM-dd} %{CurrentTime:hh:mm:ss} 29 @Modify : 日期加修改描述 30 */ 31 32 /*! 33 @ClassName : Class 34 @Description : Description 35 @Author : xxx 36 @Data : %{CurrentDate:yyyy-MM-dd} %{CurrentTime:hh:mm:ss} 37 */
作者:疯狂Delphi
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.
欢迎关注我,一起进步!扫描下方二维码即可加我
浙公网安备 33010602011771号