当前位置:网站首页>qtcreator 格式化代码
qtcreator 格式化代码
2022-06-25 22:00:00 【北极熊的奋斗史】
1. 关于 -> 插件 -> 选中Beautifier,重启qtcreator。

2. 下载astyle 官网下载: https://sourceforge.net/projects/astyle
windows 免安装,Linux需要自行编译。
3. qtcreator 重启后,打开工具 -> Beautifier,勾选 Enable auto format on file save.
4. 切换到Artistic Style,Artistic Style command,选择astyle 下载后存放的位置,我这里与qt安装目录放到了一起


5. 设置代码格式化规则

下面是我使用的代码格式话规则,方便各位复制粘贴,name随意起,我这里写的是 astyle
--style=bsd #大括号独占一行,上下对齐
--convert-tabs #将TAB符转化成空格,由转化参数指定,引号内的不转化
--indent=spaces=4 #缩进4个空格
--attach-closing-while #(while紧贴)
--indent-switches #缩进case标签
#--indent-namespaces #缩进命名空间块
--indent-continuation=4 #等号=或(结尾后续本语句符号插入空格,默认为1,可取1~4
--indent-preproc-block #缩进#开头的预处理语句
--indent-preproc-define #缩进以反斜杠结尾的多行预处理器定义
--indent-preproc-cond #预处理语句也缩进
--indent-col1-comments #注释也缩进
--pad-oper #操作符间插入空格
#--pad-comma #逗号间插入空格(--pad-oper中已有此效果)
#--pad-paren-in #括号里内插入空格
--unpad-paren #紧凑括号内外
#--delete-empty-lines #清除函数间的空行
--align-pointer=type #指针符号紧贴哪 type middle name
--align-reference=type #&符号紧贴哪 type middle name
#--break-elseifs #else if 之间换行
--add-braces #在'if', 'for', 'while'等句块中只有一行也加入大括号
--attach-return-type-decl #返回类型紧贴符号名确定,保存。
注意: 只有在代码发生修改,然后保存代码时才会生效。原来已经写好的代码,没有做过修改保存,是不会生效的。
边栏推荐
- Common MySQL database functions and queries
- STM32开发板+机智云AIoT+家庭监测控制系统
- 论文笔记: 多标签学习 MSWL
- [opencv450 samples] create image list yaml
- [opencv450 samples] inpaint restores the selected region in the image using the region neighborhood
- 1281_ FreeRTOS_ Implementation analysis of vtaskdelayuntil
- 22 years of a doctor in Huawei
- Flex & Bison 開始
- Xampp重启后,MySQL服务就启动不了。
- Flex & Bison Start
猜你喜欢

论文笔记: 多标签学习 MSWL

konva系列教程2:绘制图形

字符串

电路模块分析练习5(电源)

Idea auto generator generates constructor get/set methods, etc

Idea FAQ collection

Xinchida nd04 nd04c nrf52832 (52810) ble module (low power Bluetooth communication module) at command test

元宇宙标准论坛成立

Actual combat: how to quickly change font color in typera (blog sharing - perfect) -2022.6.25 (solved)
[email protected]@COLLATION_ CONNECTION */"/>. SQL database import error: / *! 40101 SET @OLD_ COLLATION_ [email protected]@COLLATION_ CONNECTION */
随机推荐
百度:2022年十大热度攀升专业出炉,第一名无悬念!
Flex & Bison 开始
Applets - view and logic
1281_ FreeRTOS_ Implementation analysis of vtaskdelayuntil
CAD中图纸比较功能怎么用
2、一个向量乘它的转置,其几何意义是什么?
#24class静态成员
How to solve the problem of SQL?
信息学奥赛一本通 1353:表达式括号匹配(stack) | 洛谷 P1739 表达式括号匹配
【ModuleBuilder】GP服务实现SDE中两个图层相交选取
Konva series tutorial 2: drawing graphics
剑指 Offer 46. 把数字翻译成字符串(DP)
漏刻有时API接口实战开发系列(13):小鹅通云服务PHP-API二维数组传参解决方案
Network security project questions of the first Henan vocational skills competition in 2022
Equivalence class, boundary value, application method and application scenario of scenario method
What is CDN acceleration
指针强化与提高
UE4 学习记录二 给角色添加骨架,皮肤,及运动动画
Common MySQL database functions and queries
统计字符串中不同回文子序列的个数