定义
任何开发IDE中,一般都提供snippets代码片段的功能,就是为了方便快捷的插入格式一致的代码段或者注释段。
步骤
- qt creator 添加头文件,源文件的注释功能。
- 在qt creator的"工具"->“选项”->“Snippets”,添加hfile,cppfile作为触发条件。
hfile一般是对头文件的注释,头文件的注释一般包括license和头文件信息的描述,参考如下
/**
* This file is part of the QtWidgets module of the Qt Toolkit.
* Copyright (C) 2016 The Qt Company Ltd.
* Commercial License Usage
* Licensees holding valid commercial Qt licenses may use this file in
* accordance with the commercial license agreement provided with the
* Software or, alternatively, in accordance with the terms contained in
* a written agreement between you and The Qt Company. For licensing terms
* and conditions see https://www.qt.io/terms-conditions. For further
* information use the contact form at https://www.qt.io/contact-us.
*/
/**
* @file: %{CurrentDocument:FileName}
* @brief:
* @author: 412351345@qq.com
* @date: %{CurrentDate:yyyy-MM-dd} %{CurrentTime:hh:mm}
*/
cppfile一般只包括源文件描述即可,参考:
/**
* @file: %{CurrentDocument:FileName}
* @brief:
* @author: 412351345@qq.com
* @date: %{CurrentDate:yyyy-MM-dd} %{CurrentTime:hh:mm}
*/
-
添加好后保存
-
在头文件中,输入hfile,回车即可。
- 另一个快捷键是对函数注释的,在函数声明之前输入
/**
然后回车,即可插入对函数的注释