Specify code style | Qt Creator Documentation

- Qt Creator Documentation
- Specify code style
- Qt Creator 17.0.1

How To

# Specify code style

The MIME type of the file determines which mode and editor the file opens in. Qt Creator opens C++ files in Edit mode in the C++ code editor and QML files in the Qt Quick editor.

Specify indentation for:

- C++ files
- QML files
- Nim files

Specify code style either globally or separately for each project. You can specify several sets of code style settings and easily switch between them. In addition, you can import and export code style settings.

To override the global code style for the current project:

1. Go to Projects > Project Settings > Code Style.

2. In Language, select C++, Qt Quick, or Nim.
3. For C++, clear Use global settings to use the `.clang-format` file for the project.
4. To override the project's `.clang-format` file, select Use custom settings.
5. In Custom settings, select the settings to use for the project.

In rare cases, ClangFormat can trip over a code construct and trigger a Qt Creator crash. If that happens for your project, select Use Built-In Indenter in Formatting mode to turn off ClangFormat for the project. If you can reproduce the crash, go to Help > Report Bug to report the bug and attach the code that triggers the crash to the bug report.

See also Indent text or code, Edit MIME types, C++ Code Style, Specify Qt Quick code style, and Nim.

How To