aboutsummaryrefslogtreecommitdiffstats
path: root/doc/qtcreator/src/howto/creator-only/creator-how-tos.qdoc
blob: f51b91006dcf0218cdbc3be300e231d42ff93f51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
/****************************************************************************
**
** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Creator documentation.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
**
****************************************************************************/

// **********************************************************************
// NOTE: the sections are not ordered by their logical order to avoid
// reshuffling the file each time the index order changes (i.e., often).
// Run the fixnavi.pl script to adjust the links to the index order.
// **********************************************************************

/*!
    \previouspage creator-faq.html
    \page creator-how-tos.html
    \nextpage creator-known-issues.html

    \title How-tos

    How do I:

    \list
    \li \l {Switch between modes}
    \li \l {Move between open files}
    \li \l {Switch to Edit mode}
    \li \l {Find a specific setting}
    \li \l {Open output panes}
    \li \l {Find keyboard shortcuts}
    \li \l {Run \QC from the command line}
    \li \l {Show and hide sidebars}
    \li \l {Move to symbols}
    \li \l {Inspect signal-slot connections while debugging}
    \li \l {Display low-level data in the debugger}
    \li \l {See the value of variables in tooltips while debugging}
    \li \l {Quickly locate files using the keyboard}
    \li \l {Perform calculations}
    \li \l {Jump to a function in QML code}
    \li \l {Add a license header template for C++ code}
    \li \l {Paste text from my clipboard history}
    \li \l {Sort lines alphabetically}
    \li \l {Enclose selected code in curly braces, parentheses, or double quotes}
    \li \l {Select the enclosing block in C++}
    \li \l {Add my own code snippets to the auto-complete menu}
    \li \l {Quickly write down notes somewhere}
    \li \l {Configure the amount of recent files shown}
    \li \l {Search and replace across files using a regular expression}
    \endlist

    \section1 Switch between modes

    \QC uses different modes for different purposes. You can quickly
    switch between these modes with the following keyboard shortcuts:

    \list

        \li \uicontrol Welcome mode \key Ctrl+1
        \li \uicontrol Edit mode \key Ctrl+2
        \li \uicontrol Design mode \key Ctrl+3
        \li \uicontrol Debug mode \key Ctrl+4
        \li \uicontrol Projects mode \key Ctrl+5
        \li \uicontrol Help mode \key Ctrl+6

    \endlist

    For more information about \QC modes, see \l {Selecting Modes}.

    \section1 Move between open files

    To quickly move between currently open files, press
    \key Ctrl+Tab.

    To move forward in the location history, press \key {Alt+Right}
    (\key {Cmd+Opt+Right} on \macos). To move backward, press \key {Alt+Left}
    (\key {Cmd+Opt+Left} on \macos). For example, if you use the \uicontrol Locator
    to jump to a symbol in the same file, you can jump back to your original
    location in that file by pressing \key {Alt+Left}.

    \section1 Switch to Edit mode

    To move to the \uicontrol Edit mode and currently active file, press
    \key Esc.

    If you already are in the \uicontrol Edit mode:

    \list

        \li The first press moves focus to the editor

        \li The second press closes secondary windows

    \endlist

    \section1 Find a specific setting

    To find specific settings you require in \uicontrol{Tools} > \uicontrol{Options}
    use the filter located at the top left of the \uicontrol Options dialog box.

    \section1 Open output panes

    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:

    \list

        \li \uicontrol{Issues} pane Alt+1 (Cmd+1 on \macos)

        \li \uicontrol{Search Results} pane Alt+2 (Cmd+2 on \macos)

        \li \uicontrol{Application Output} pane Alt+3 (Cmd+3 on \macos)

        \li \uicontrol{Compile Output} pane Alt+4 (Cmd+4 on \macos)

    \endlist

    To open the other output panes, such as \uicontrol{General Messages} and
    \uicontrol{Version Control}, select \uicontrol Window > \uicontrol {Output Panes}. The menu
    items also display the keyboard shortcuts that you can use.

    For more information about output panes, see \l{Viewing Output}.

    \section1 Find keyboard shortcuts

    \QC provides \l{Keyboard Shortcuts}{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 \uicontrol Tools >
    \uicontrol Options > \uicontrol Environment > \uicontrol Keyboard.

    \section1 Run \QC from the command line

    You can launch \QC from command line using the name of an
    existing session or \c .pro file by giving the name as the command
    argument.

    For example, running \tt{qtcreator somesession}, launches \QC and
    loads session somesession.

    For more information, see \l{Using Command Line Options}.

    \section1 Show and hide sidebars

    You can toggle the left and right sidebar in some \QC modes.

    To toggle the left sidebar, click \inlineimage leftsidebaricon.png
    (\uicontrol {Hide Left Sidebar/Show Left Sidebar}) or press \key Alt+0
    (\key Cmd+0 on \macos).

    To toggle the right sidebar, click \inlineimage rightsidebaricon.png
    (\uicontrol {Hide Right Sidebar/Show Right Sidebar}) or press
    \key Alt+Shift+0 (\key Cmd+Shift+0 on \macos).

    For more information on using the sidebars, see
    \l {Browsing Project Contents}.

    \section1 Move to symbols

    To move straight to a symbol used in a project, select the symbol in the
    \uicontrol Editor toolbar drop-down menu. For more information on the editor
    toolbar, see \l {Using the Editor Toolbar}.

    To jump to a symbol in the current file, press \key {Ctrl+K} to open the
    \uicontrol 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 \l{Searching with the Locator}.

    Press \key Ctrl (\key 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 \key {F2}. For more information, see
    \l{Moving to Symbol Definition or Declaration}.

    \section1 Inspect signal-slot connections while debugging

    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 \uicontrol Tools > \uicontrol Options
    > \uicontrol{Debugger} > \uicontrol{Locals} > \uicontrol{Use Debugging Helper}.

    In the \uicontrol{Locals} view, expand the object's entry and open
    the slot in the \e slots subitem. The objects connected to this slot are
    shown as children of the slot. This method works with signals too.

    For more information about the \uicontrol{Locals} view, see
    \l{Local Variables and Function Parameters}.

    \section1 Display low-level data in the debugger

    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:
    \list 1

        \li Select \uicontrol Tools > \uicontrol Options > \uicontrol Debugger >
            \uicontrol{Locals}.

        \li Uncheck the \uicontrol{Use Debugging Helper} checkbox.

    \endlist

    \section1 See the value of variables in tooltips while debugging

    To inspect the value of variables from the editor, you can turn
    on tooltips. Tooltips are hidden by default for performance reasons.

    \list 1

        \li Select \uicontrol Tools > \uicontrol Options >
            \uicontrol Debugger > \uicontrol General.

        \li Select the \uicontrol {Use tooltips in main editor while debugging} check
            box.

    \endlist

    When you hover over a variable in the code editor in \uicontrol 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.

    \image qtcreator-pin-tooltip.png

    Pinned tooltips are stored in the session. To close all pinned tooltips,
    select \uicontrol {Close Editor Tooltips} in the context menu in the
    \uicontrol {Locals} view.

    \section1 Quickly locate files using the keyboard

    The \uicontrol Locator provides one of the easiest ways in \QC 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 \uicontrol Tools > \uicontrol Options >
    \uicontrol Locator > \uicontrol Add.

    For more information, see \l{Creating Locator Filters}.

    \section1 Perform calculations

    Open the \uicontrol Locator with \key {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 \key {Enter}.

    For more information, see \l{Executing JavaScript}.

    \section1 Jump to a function in QML code

    Open the \uicontrol Locator with \key {Ctrl+K} and type m, followed by a space.
    You can now go directly to any QML method in the file.

    \section1 Add a license header template for C++ code

    A file containing a license header for C++ can be specified under
    \uicontrol Tools > \uicontrol Options > \uicontrol C++ >
    \uicontrol {License Template}. It may contain special placeholders enclosed
    in \c{%%} that are replaced when generating a new file:

    \list 1

        \li \c %YEAR%: Year
        \li \c %MONTH%: Month
        \li \c %DAY%: Day of the month
        \li \c %DATE%: Date
        \li \c %USER%: Username
        \li \c %FILENAME%: File name
        \li \c %CLASS%: Class name (if applicable)
        \li \c %$VARIABLE%: Contents of environment variable \c{VARIABLE}.

    \endlist

    \section1 Paste text from my clipboard history

    \QC stores copied text in clipboard history. To retrieve clips from the
    history, press \key {Ctrl+Shift+V} until the clip appears.
    The number of clips in the history is fixed to 10.

    \section1 Sort lines alphabetically

    To sort selected lines alphabetically, select \uicontrol Edit >
    \uicontrol Advanced > \uicontrol {Sort Selected Lines} or press
    \key {Alt+Shift+S} (or \key Ctrl+Shift+S on \macos).

    \section1 Enclose selected code in curly braces, parentheses, or double quotes

    Press \key {Shift} and then the opening character.

    \list
    \li Curly braces: \key {Shift+\{}
    \li Parentheses: \key {Shift+(}
    \li Double quotes: \key {Shift+"}
    \endlist

    \section1 Select the enclosing block in C++

    Press \key {Ctrl+U}.

    \section1 Add my own code snippets to the auto-complete menu

    You can add, modify, and remove snippets in the snippet editor.
    To open the editor, select \uicontrol Tools > \uicontrol Options
    > \uicontrol {Text Editor} > \uicontrol Snippets.

    For more information, see \l {Adding and Editing Snippets}.

    \section1 Quickly write down notes somewhere

    Select \uicontrol File > \uicontrol {New File or Project} >
    \uicontrol {Files and Classes} > \uicontrol General > \uicontrol {Scratch Buffer}.
    Alternatively, \key {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 \uicontrol File > \uicontrol {Recent Files} menu.

    \section1 Configure the amount of recent files shown

    Select \uicontrol Tools > \uicontrol Options, and change the value of the
    list under \uicontrol Environment > \uicontrol System
    > \uicontrol {Maximum number of entries in "Recent Files"}.

    \section1 Search and replace across files using a regular expression

    As an example, say you want to replace equality checks (\c {foo == bar})
    with a function (\c {foo.equals(bar)}):

    \list 1
    \li Ensure that any work you have done is committed to version control,
        as the changes cannot be undone.
    \li Press \key {Ctrl+Shift+F} to bring up the \uicontrol {Advanced Find}
        form.
    \li Change the scope to whatever is appropriate for your search.
    \li Under the \uicontrol {Search for} text field, select
        the \uicontrol {Use regular expressions} check box.
    \li Enter the following text in the \uicontrol {Search for} text field:
        \badcode
        if \((.*) == (.*)\)
        \endcode
    \li Press \uicontrol {Search & Replace} to see a list of search results.
    \li In the \uicontrol {Replace with} text field, enter the following text:
        \badcode
        if (\1.strictlyEquals(\2))
        \endcode
    \li Press \uicontrol Replace to replace all instances of the text.
    \endlist

    For more information, see \l {Advanced Search}.
*/