- Qt Creator Documentation
- Specify Qt Quick code style
- Qt Creator 18.0.0-beta1

How To

# 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.
5. For the built-in formatter, 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.

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

## Qmlformat global configuration

When you select qmlformat as the formatter, you can configure it globally by editing the Qmlformat global configuration field. This field uses the same format as a `.qmlformat.ini` file and overrides the `.qmlformat.ini` file in the generic configuration location (QStandardPaths::GenericConfigLocation).

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 configuration is used. For information about configuring QML formatting options, 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.

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

How To