指定代码样式
Qt Creator 在 C++ 代码编辑器中以Edit 模式打开 C++ 文件,在Qt Quick 编辑器中打开 QML 文件。
指定缩进:
- C++ 文件
- QML 文件
- Nim 文件
为每个项目全局或单独指定代码样式。您可以指定多套代码样式设置,并在它们之间轻松切换。此外,还可以导入和导出代码样式设置。
要覆盖当前项目的全局代码样式,请执行以下操作
- 转到Projects >Project Settings >Code Style 。
- 在Language 中,选择C++ 、 Qt Quick, 或Nim 。
- 对于 C++,清除Use global settings 以使用项目的
.clang-format
文件。 - 要覆盖项目的
.clang-format
文件,请选择Use custom settings 。 - 在Custom settings 中,选择要用于项目的设置。
在极少数情况下,ClangFormat可能会被代码结构绊倒并触发Qt Creator 崩溃。如果您的项目出现这种情况,请在Formatting mode 中选择Use Built-In Indenter ,关闭项目的 ClangFormat。如果可以重现崩溃,请访问Help >Report Bug 报告错误,并在错误报告中附上引发崩溃的代码。
Copyright © The Qt Company Ltd. and other contributors. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.