Qt

Working in Edit Mode

This section describes how to use the Edit mode. For more information about using the sidebar, see Browsing Project Contents.

Using the Editor Toolbar

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 backward or forward through your location history, click (Go Back) and (Go Forward).

To go to any open file, select it from the Open files drop-down menu (1). 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 (2). 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.

To jump to a line and column in the current file, select the line and column indicator (3) or press Ctrl+L (or Cmd+L on Mac OS X) to open the locator. Enter the line number and column number in the locator, separated by a colon (:).

To show the file encoding of the current file on the editor toolbar (4), select Tools > Options > Text Editor > Display > Display file encoding.

Note: Other convenient ways of navigating in Qt Creator are provided by the locator, keyboard shortcuts, and the sidebar.

Splitting the Editor View

Split the editor view or open the editor in a new window when you want to work on and view multiple files on the same screen or on multiple screens.

You can view multiple files simultaneously in the following ways:

  • To split the editor view into a top and bottom view, select Window > Split, press Ctrl+E, 2, or select the (Split) button and then select Split.

    Split command creates views below the currently active editor view.

  • To split the editor view into adjacent views, select Window > Split Side by Side, press Ctrl+E, 3, or select Split > Split Side by Side.

    Side by side split command creates views to the right of the currently active editor view.

  • To open the editor in a detached window, press Ctrl+E, 4, or select Window > Open in New Window.

    The new window behaves basically in the same way as the editor area in the main window. For example, you can split this window, as well. Documents are opened in the currently active editor window.

To move between split views and detached editor windows, select Window > Go to Next Split or Window 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, press Ctrl+E, 0, or select the (Remove Split) button. To remove all but the currently selected split view, select Window > Remove All Splits or press Ctrl+E, 1.

Using Bookmarks

To insert or delete a bookmark:

  • Right-click the line number and select Toggle Bookmark.
  • Press Shift and click the left margin at a line.
  • Press Ctrl+M when the cursor is on a line.

To add a note to a bookmark, right-click the bookmark and select Edit Bookmark Note. To view the note, move the mouse pointer over the bookmark.

To go to previous bookmark in the current session, press Ctrl+,.

To go to next bookmark in the current session, press Ctrl+..

Moving to Symbol Definition or Declaration

You can move directly to the definition or the declaration of a symbol by holding the Ctrl and clicking the symbol. If you have multiple splits opened, you can open the link in the next split by holding Ctrl and Alt while clicking on 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 feature 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.

Links are opened in the same split by default. To open links in the next split, prepend Ctrl+E to the shortcut. For example, press Ctrl+E,F2 to follow the symbol in the next split. If necessary, the view is automatically split. To change the default behavior, select Tools > Options > Text Editor > Display, and then select Always Open Links in Next Split. Additional symbols are displayed and switching between definition and declaration is done in another split. If you change the default behavior, the shortcuts for opening link targets in the next split are used to open them in the current split.

Using Update Code Model

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.