• Qt Creator- Beautifier插件代码格式化,使用 Clang Code Model


    一 . 使用Clang Code模式来提醒语法和格式错误:

    1. 在插件中勾选 ClangCodeModle选项

    2. 新建检测配置, 进入 Tools→Options→C++, 在Code Model标签页,点击Manage按照需要编辑

     

    ClangCodeModle配置(供参考):

    -Weverything -Wno-unused-macros -Wno-newline-eof -Wno-exit-time-destructors -Wno-global-constructors -Wno-gnu-zero-variadic-macro-arguments 
    -Wno-documentation -Wno-shadow -Wno-missing-prototypes -Wno-old-style-cast -Wno-deprecated -Wno-c++11-long-long -Wno-c++98-compat-pedantic
    -Wno-writable-strings -Wno-covered-switch-default -Wno-variadic-macros -Wsuggest-attribute=pure -Wno-c++11-extensions -Wno-expansion-to-defined
    -Wno-missing-field-initializers -Wno-zero-as-null-pointer-constant -Wno-disabled-macro-expansionue 

    官方教程: https://doc.qt.io/qtcreator/creator-clang-codemodel.html

    https://www.oschina.net/news/98177/qt-creator-4-7-0-released

    二) 代码格式化工具

    QtCreator提供了一个Beautifier插件,用于加载外部工具(Artistic Style、ClangFormat、Uncrustify)对代码进行格式化。

    Beautifier会将源代码解析为结构模块,如赋值语句、IF语句块、循环体等等,并用Beautifier指定的选项对模块进行格式化。
    Beautifier可以使用预定义和自定义风格对代码进行格式化。

    1.首先确认插件是否安装

     2.配置

     

     

      

      

    BasedOnStyle: LLVM
    BreakBeforeBraces: Custom
    BraceWrapping:
    AfterClass: true
    AfterControlStatement: true
    AfterEnum: true
    AfterFunction: true
    AfterNamespace: true
    AfterObjCDeclaration: false
    AfterStruct: true
    AfterUnion: true
    BeforeCatch: false
    BeforeElse: true
    IndentBraces: false
    BinPackParameters: false
    BinPackArguments: false
    Cpp11BracedListStyle: false
    IndentWidth: 2
    Standard: Cpp03
    ColumnLimit: 80

    3 设置快捷键 Ctrl+ALt+I ,然后可以选中要格式化的代码使用 Ctrl+ALt+I 

      

    其他格式可参考:https://blog.51cto.com/9291927/2112402

  • 相关阅读:
    KindEditor自动过滤首行缩进和全角空格的解决方法
    网站流量、连接数等监控
    VSFTP的使用
    CentOs 设置静态IP
    MySQL 5.7版本sql_mode=only_full_group_by问题
    使用密钥登录CentOS系统(基于密钥的认证)
    FIRMWARE BUG – THE BIOS HAS CORRUPTED HW-PMU RESOURCES
    Ubuntu上的MySQL可以远程访问
    自动生成单据编号
    SQL Server 重置SA密码语句
  • 原文地址:https://www.cnblogs.com/7star/p/12372094.html
Copyright © 2020-2023  润新知