How do I:
Qt Creator uses different modes for different purposes. You can quickly switch between these modes with the following keyboard shortcuts:
For more information about Qt Creator modes, see Selecting Modes .
To quickly move between currently open files, press Ctrl+Tab .
To move forward in the location history, press Alt+Right ( Cmd+Opt+Right on macOS). To move backward, press Alt+Left ( Cmd+Opt+Left on macOS). For example, if you use the Locator to jump to a symbol in the same file, you can jump back to your original location in that file by pressing Alt+Left .
To move to the Edit mode and currently active file, press Esc .
If you already are in the Edit mode:
To find specific settings you require in 工具 > Options use the filter located at the top left of the Options 对话框。
The output panes provide a list of errors and warnings encountered during a build, detailed output from the compiler, status of a program when it is executed and debug output, as well as search results.
To open output panes, use the following shortcuts:
To open the other output panes, such as General Messages and Version Control , select View > Output Panes . The menu items also display the keyboard shortcuts that you can use.
For more information about output panes, see Viewing Output .
Qt Creator provides many useful keyboard shortcuts . You can see the keyboard shortcut for a menu command in the menu or the tooltip for a button.
To customize, import or export keyboard shortcuts, select 工具 > Options > Environment > Keyboard .
You can launch Qt Creator from command line using the name of an existing session or
.pro
file by giving the name as the command argument.
For example, running
qtcreator somesession
, launches Qt Creator and loads session somesession.
更多信息,见 使用命令行选项 .
You can toggle the left and right sidebar in some Qt Creator modes.
To toggle the left sidebar, click
(
Hide Left Sidebar/Show Left Sidebar
) or press
Alt+0
(
Cmd+0
on macOS).
To toggle the right sidebar, click
(
Hide Right Sidebar/Show Right Sidebar
) or press
Alt+Shift+0
(
Cmd+Shift+0
on macOS).
For more information on using the sidebars, see Browsing Project Contents .
To move straight to a symbol used in a project, select the symbol in the Editor toolbar drop-down menu. For more information on the editor toolbar, see Using the Editor Toolbar .
To jump to a symbol in the current file, press Ctrl+K to open the Locator , enter a period (.), and start typing the symbol name. Then select the symbol in the list. For more information on using the locator, see Searching with the Locator .
Press Ctrl ( Cmd on macOS) and click a symbol to move directly to the definition or the declaration of the symbol. You can also move the cursor on the symbol and press F2 。更多信息,见 Moving to Symbol Definition or Declaration .
If an instance of a class is derived from QObject , and you would like to find all other objects connected to one of your object's slots using Qt's signals and slots mechanism, select 工具 > Options > Debugger > Locals > Use Debugging Helper .
在 Locals view, expand the object's entry and open the slot in the slots subitem. The objects connected to this slot are shown as children of the slot. This method works with signals too.
更多信息有关 Locals view, see Local Variables and Function Parameters .
If special debugging of Qt objects fails due to data corruption within the debugged objects, you can switch off the debugging helpers. When debugging helpers are switched off low-level structures become visible.
To switch off the debugging helpers:
To inspect the value of variables from the editor, you can turn on tooltips. Tooltips are hidden by default for performance reasons.
When you hover over a variable in the code editor in Debug mode, a tooltip is displayed. To keep the tooltip visible, click the pin button. You can expand pinned tooltips to view their full content.
Pinned tooltips are stored in the session. To close all pinned tooltips, select Close Editor Tooltips in the context menu in the Locals view.
The Locator provides one of the easiest ways in Qt Creator to browse through projects, files, classes, functions, documentation and file systems. To quickly access files not directly mentioned in your project, you can create your own locator filters. That way you can locate files in a directory structure you have defined.
To create locator filters, select 工具 > Options > Locator > Add .
更多信息,见 Creating Locator Filters .
打开 Locator with Ctrl+K and type =, followed by a space. You can now do basic calculations, with options to copy the results to the clipboard by navigating through the entries and pressing Enter .
更多信息,见 Executing JavaScript .
打开 Locator with Ctrl+K and type m, followed by a space. You can now go directly to any QML method in the file.
A file containing a license header for C++ can be specified under
工具
>
Options
>
C++
>
License Template
. It may contain special placeholders enclosed in
%%
that are replaced when generating a new file:
%YEAR%
: Year
%MONTH%
: Month
%DAY%
: Day of the month
%DATE%
: Date
%USER%
: Username
%FILENAME%
: File name
%CLASS%
: Class name (if applicable)
%$VARIABLE%
: Contents of environment variable
VARIABLE
.
Qt Creator stores copied text in clipboard history. To retrieve clips from the history, press Ctrl+Shift+V until the clip appears. The number of clips in the history is fixed to 10.
To sort selected lines alphabetically, select Edit > 高级 > Sort Selected Lines or press Alt+Shift+S (or Ctrl+Shift+S on macOS).
Press Shift and then the opening character.
Press Ctrl+U .
You can add, modify, and remove snippets in the snippet editor. To open the editor, select 工具 > Options > 文本编辑器 > Snippets .
更多信息,见 Adding and Editing Snippets .
选择 File > New File or Project > Files and Classes > General > Scratch Buffer . Alternatively, Ctrl+N can be used to open this dialog, which is fully navigable via keyboard by using the up and down arrow keys and the tab key.
This creates a new empty text file and saves it to the temporary directory on your machine. You can use it to write down notes without having to worry about deleting the file afterwards. The operating system will eventually remove the file automatically. If you want to keep the file, you can easily save it as a new file somewhere else. If you accidentally close the file, you can find it in the File > Recent Files 菜单。
选择 工具 > Options , and change the value of the list under Environment > 系统 > Maximum number of entries in "Recent Files" .
As an example, say you want to replace equality checks (
foo == bar
) with a function (
foo.equals(bar)
):
if \((.*) == (.*)\)
if (\1.strictlyEquals(\2))
更多信息,见 Advanced Search .