Specify Qt Quick code style | Qt Creator Documentation

- Qt Creator Documentation
- Specify Qt Quick code style
- Qt Creator 19.0.1

Select the current code block ◦ Split the editor view

# Specify Qt Quick code style

You can use the built-in code formatter (deprecated) or an external tool, such as qmlformat, to automatically format QML files according to QML coding conventions.

To specify QML code style globally:

1. Go to Preferences > Qt Quick > Code Style.
2. In Custom settings, select the settings to modify, and then select Copy.

3. Give a name to the settings, and select OK.
4. In Formatter Selection, select the formatter to use.

To override the global preferences for a particular project, select Projects > Code Style.

## Use the built-in formatter

The built-in formatter has been deprecated in favor of the qmlformat tool or a custom formatter.

To set global preferences for the built-in formatter:

1. In Formatter Selection, select Built-in formatter.
2. Specify how to interpret the Tab key presses and how to align continuation lines, as well as set the maximum line length for code lines.

## Use qmlformat

To set global preferences for the qmlformat tool:

1. In Formatter Selection, select QMLFormat.

2. In Global qmlformat Configuration, set the code style. The changes you make override the `.qmlformat.ini` file in the generic configuration location (QStandardPaths::GenericConfigLocation).
3. To add a copy of the global `qmlformat` configuration file to your project, select Deploy INI File to Current Project.

The qmlformat tool searches for a `.qmlformat.ini` file in the same directory as the file being formatted. If it is not found, it searches the parent directories up to the root directory. If no `.qmlformat.ini` file is found, the global preferences are used. For more information, see the qmlformat configuration settings.

Note: If a custom `.qmlformat.ini` file exists in the project directory or any parent directory, it takes precedence over the global configuration.

## Use a custom tool

To use a custom tool that is compatible with qmlformat:

1. In Formatter Selection, select Custom formatter.

2. In Command, enter the path to the tool.
3. In Arguments, enter options for running the tool.
4. View the code style set in a `.qmlformat.ini` file on the right.

See also Automatically format QML/JS files, Find preferences, Indent text or code, and Specify code style.

Select the current code block ◦ Split the editor view