Subnavigation

New indenter settings

A couple of days ago, new indenter settings were merged into the Qt Creator master repository. Below, you can find a brief description of how the indenter works and what it can do.

Global Code Style Settings

For the C++ indenter, you can now choose how to indent content (separately for classes, methods, blocks and namespaces) and how to indent braces (of classes, namespaces, enums, methods and blocks). You can have detailed control over switch statements and their contents. It is also possible to influence the behaviour of alignment for continuation lines.

The new C++ indenter options can be found in the Options dialog (called Preferences on Mac OS X), under the "C++" category, in the "Code Style" tab. In addition, you can specify your own tab settings in the "General" tab, which will be applied only for the C++ editor, or you can choose to use global tab settings for C++ (the default). Change of any option is instantly reflected in a live preview, where content can be modified.

Project Code Style Settings

C++ code style settings can be different for every project you are working on. The project settings overwrite global settings. However, if you are fine with your global settings, you can easily use them for your project (the default). In order to change code style settings for you project, switch to "Project" mode, select your desired project from top tab bar and select "Code Style Settings". If you uncheck the "Use global C++ settings" checkbox, you are free to modify code style settings for your project. In addition, "General" tab contains "Settings" combobox - here you can select which tab settings should be used for C++ files in your project. You can specify your own C++ tab settings by selecting "Custom" or you can specify that tab settings should be taken from "Global text editor" settings, "Global C++" settings or from "Project text editor" settings (which can be set in "Editor Settings" in the Project mode).

Tab Settings

In addition, it's now possible to specify tab settings separately for different languages. Currently, C++ and QML/JS are supported. Tab settings specific to the language can be set for both global and project scopes. For global level, they can be found in Options under specific language category ("C++" and "Qt Quick", respectively). For project level, they can be found under "Code Style Settings" in the Project mode and selected in the "Language" combobox.

The current solution allows you to set tab settings at 4 different levels:

  1. Global: for all editors
  2. Global C++ / Qt Quick: for C++ / QmlJs editors
  3. Project: for all editors of files which belong to the project
  4. Project C++ / Qt Quick: for C++ / QmlJs editors of files which belong the the project

The green arrows show the possible fallbacks which can be specified for tab settings from each level.

OK, so let's say you have one project open and your tab size settings look like in the above picture. Which tab size is used in your editors? Here are a couple of examples:

  • foo.cpp which belongs to your project: 8
  • foo.txt which belongs to your project: 6
  • bar.cpp which is not in your project: 4
  • bar.txt which is not in your project: 2

Storing Project Settings

Currently (as it was with editor settings in Qt Creator 2.2), settings are stored in .user files. However, the plan is to store them in a separate file so that they can be stored in project repositories and shared between users.

Any suggestions are appreciated: http://bugreports.qt.nokia.com


Blog Topics:

Comments