clang-format for Qt Creator

在多人合作的项目中,每个人都有自己的代码格式风格,所以统一风格很重要,幸好Qt Creator提供了插件可以自定义格式化工具,这里我用的是clang-format这个格式化工具,具体我们的项目统一使用的设置如下。

BasedOnStyle: Google
IndentWidth: 4
TabWidth: 4
AlwaysBreakTemplateDeclarations: true
AllowShortFunctionsOnASingleLine: Inline 
BreakBeforeBraces: Linux
IndentCaseLabels: true
AccessModifierOffset: -4
BreakBeforeBraces: Custom
BraceWrapping:
    AfterClass: true
    AfterControlStatement: false
    AfterEnum:       true
    AfterFunction:   true
    AfterNamespace:  false
    AfterStruct:     true
    AfterUnion:      true

BreakConstructorInitializersBeforeComma: true
ConstructorInitializerAllOnOneLineOrOnePerLine: true
BinPackParameters: false
BinPackArguments: false
ReflowComments: false

Language: Cpp
ColumnLimit: 120

ForEachMacros:   
  - foreach
  - Q_FOREACH
  - BOOST_FOREACH
  - Q_localarea
Standard: Cpp11

AlignTrailingComments: true
PointerAlignment: Right
MaxEmptyLinesToKeep: 1
FixNamespaceComments: true
AlignConsecutiveDeclarations: true
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignEscapedNewlinesLeft: true
AllowAllParametersOfDeclarationOnNextLine: true

Written by 

你来或不来,我都在这里等你~

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注