Qt Creator's code editor is designed to aid you in creating, editing and navigating code. Qt Creator's code editor is fully equipped with syntax checking, code completion, context sensitive help and in-line error indicators while you are typing.

The editor toolbar is located at the top of the editor view. The editor toolbar is context sensitive and shows items relevant to the file currently open in the editor.

Use the toolbar to navigate between open files and symbols in use. To browse forward or backward through your location history, click
and
.
To go to any open file, select it from the Open files drop-down menu. Right-click the menu title and select Copy Full Path to Clipboard to copy the path and name of the current file to the clipboard.
To jump to any symbol used in the current file, select it from the Symbols drop-down menu. By default, the symbols are displayed in the order in which they appear in the file. Right-click the menu title and select Sort Alphabetically to arrange the symbols in alphabetic order.
Split the editor view when you want to work on and view multiple files on the same screen.

You can split the editor view in the following ways:
Split command creates views below the currently active editor view.
Side by side split command creates views to the right of the currently active editor view.
To move between split views, select Window > Go to Next Split or press Ctrl+E, O.
To remove a split view, place the cursor within the view you want to remove and select Window > Remove Current Split or press Ctrl+E, 0. To remove all but the currently selected split view, select Window > Remove All Splits or press Ctrl+E, 1.
Qt Creator understands the C++ and QML languages as code, not as plain text. It reads the source code, analyzes it, and highlights it based on the semantic checks that it does for the following code elements:
To specify the color scheme to use for semantic highlighting, select Tools > Options... > Text Editor > Fonts & Color.
Qt Creator supports syntax highlighting also for other types of files than C++ or QML. For more information, see Generic Highlighting.
Use block highlighting to visually separate parts of the code that belong together. For example, when you place the cursor within the braces, the code enclosed in braces is highlighted.

To enable block highlighting, select Tools > Options... > Text Editor > Display > Highlight blocks.
Use the folding markers to collapse and expand blocks of code within braces. Click the folding marker to collapse or expand a block. In the figure above, the folding markers are located between the line number and the text pane.
To show the folding markers, select Tools > Options... > Text Editor > Display > Display folding markers. This option is enabled by default.
When the cursor is on a brace, the matching brace is animated by default. To turn off the animation and just highlight the block and the braces, select Tools > Options... > Text Editor > Display and deselect Animate matching parentheses.
As you write code Qt Creator checks code syntax. When Qt Creator spots a syntax error in your code it underlines it and shows error details when you move the mouse pointer over the error.
In the following figure, a semicolon is missing at the end of the line.

In the following figure, the type is unknown.

As you write code, Qt Creator suggests properties, IDs, and code snippets to complete the code. It provides a list of context-sensitive suggestions to the statement currently under your cursor.

To open the list of suggestions at any time, press Ctrl+Space. If only one option is available, Qt Creator inserts it automatically.
When completion is invoked manually, Qt Creator completes the common prefix of the list of suggestions. This is especially useful for classes with several similarly named members. To disable this functionality, uncheck Autocomplete common prefix in the code completion preferences. Select Tools > Options... > Text Editor > Completion.
By default, code completion considers only the first letter case-sensitive. To apply full or no case-sensitivity, select the option in the Case-sensitivity field.
The following table lists available types for code completion and icon used for each.
| Icon | Description |
|---|---|
| A class |
| An enum |
| An enumerator (value of an enum) |
| A function |
| A private function |
| A protected function |
| A variable |
| A private variable |
| A protected variable |
| A signal |
| A slot |
| A private slot |
| A protected slot |
| A C++ keyword |
| A C++ code snippet |
| A QML element |
| A QML code snippet |
| A macro |
| A namespace |
Code snippets can consist of multiple fields that you specify values for. Select an item in the list and press Tab or Enter to complete the code. Press Tab to move between the fields and specify values for them.

To insert or delete a bookmark right-click the line number and select Toggle Bookmark or press Ctrl+M.

To go to previous bookmark in the current session, press Ctrl+,.
To go to next bookmark in the current session, press Ctrl+..
In Qt Creator you can move directly to the definition or the declaration of a symbol by holding the Ctrl and clicking the symbol.
To enable this moving function, in Tools > Options... > Text Editor > Behavior, select Enable mouse navigation.
You can also select the symbol and press F2, or right-click the symbol and select Follow Symbol Under Cursor to move to its definition or declaration. This is supported for namespaces, classes, methods, variables, include statements, and macros.
To switch between the definition and declaration of a symbol, press Shift+F2 or right-click the symbol and select Switch Between Method Declaration/Definition.
To view the base classes of a class, right-click the class and select Open Type Hierarchy or press Ctrl+Shift+T.
To refresh the internal information in Qt Creator pertaining to your code, select Tools > C++ > Update Code Model.
Note: In Qt Creator indexing updates the code automatically. Use Update Code Model only as an emergency command.
[Previous: Adding New Custom Wizards] [Next: Finding and Replacing]