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
|
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\page creator-editor-quick-fixes.html
\if defined(qtdesignstudio)
\previouspage creator-editor-refactoring.html
\else
\previouspage creator-how-tos.html
\endif
\ingroup creator-how-to-edit
\title Apply quick fixes
To apply quick fixes while refactoring code, select them in a context menu
in the code editor. The fixes available depend on the position of the
cursor in the code editor.
\list 1
\if defined(qtcreator)
\li To apply quick fixes:
\list
\li In C++ code, right-click an operand, conditional statement,
string, or name.
\li In QML code, right-click an item ID or name.
\endlist
\else
\li To apply quick fixes to QML code, right-click an item ID or name.
\endif
\li In the context menu, go to \uicontrol {Refactoring} and then select a
quick fix.
\endlist
Or, press \key {Alt+Enter} to open a context menu that has
quick fixes available in the current cursor position.
\if defined(qtcreator)
\section1 Create functions
Apply quick fixes to implement member functions, insert
virtual functions of base classes, create getter and setter functions,
and generate constructors. Specify settings for generating the
functions either globally for all projects or separately for each project
in the \l{Configuring Projects}{build and run} settings of the project.
\section2 Implement member functions
Apply the \uicontrol {Create Implementations for Member Functions}
quick fix to create implementations for all member functions in
one go. In the \uicontrol {Member Function Implementations} dialog,
specify whether the member functions are generated inline or outside the
class.
\image qtcreator-refactoring-member-function-implementations.png "Implement Member Functions dialog"
\section2 Insert virtual functions
Apply the \uicontrol {Insert Virtual Functions of Base Classes}
quick fix to insert declarations and the corresponding definitions
inside or outside the class or in an implementation file (if it exists).
\image qtcreator-refactoring-virtual-function-dialog.png "Insert Virtual Functions dialog"
Select the functions to insert in the list of available functions.
Filter the list and hide reimplemented functions from it.
You can add \e virtual or the \e override equivalent to the function
declaration.
\section2 Create getters and setters
Apply the \uicontrol {Create Getter and Setter Member Functions}
quick fix to create either both getter and setter member functions
for member variables or only a getter or setter.
\image qtcreator-refactoring-getters-and-setters.png "Getters and Setters dialog"
\section2 Generate constructors
Apply the \uicontrol {Generate Constructor} quick fix to
create a public, protected, or private constructor for a class. Select the
class members to initialize in the constructor. Drag the parameters
to specify their order in the constructor.
\image qtcreator-refactoring-constructor.png "Constructor dialog"
\sa {Specify settings for quick fixes}, {Quick Fixes}, {C++ Quick Fixes}
\endif
\sa {QML Quick Fixes}, {Refactoring}
*/
/*!
\page creator-reference-qml-quick-fixes.html
\if defined(qtdesignstudio)
\previouspage creator-editor-refactoring.html
\else
\previouspage creator-reference.html
\endif
\ingroup creator-reference
\title QML Quick Fixes
\brief Summary of quick fixes for QML code.
Apply the following types of quick fixes to QML code:
\list
\li Rename IDs
\li Split initializers
\li Move a QML type into a separate file to reuse it in other .qml files
\endlist
The following table summarizes the quick fixes for QML code. The
action is available when the cursor is in the position described in the
Activation column.
\table
\header
\li Quick Fix
\li Description
\li Activation
\row
\li Move Component into Separate File
\li Moves a QML type into a separate file. Give the new component a
name and select whether properties are set for the new component
or for the original one.
\image qtcreator-move-component-into-separate-file.png
\li QML type name.
\if defined(qtdesignstudio)
This action is also available in the \l {2D} view.
\endif
\row
\li Split Initializer
\li Reformats a one-line type into a multi-line type. For example,
rewrites
\code
Item { x: 10; y: 20; width: 10 }
\endcode
as
\code
Item {
x: 10;
y: 20;
width: 10
}
\endcode
\li QML type property
\row
\li Wrap Component in Loader
\li Wraps the type in a Component type and loads it dynamically in a
Loader type. This is usually done to improve startup time.
\li QML type name
\row
\li Add a message suppression comment
\li Prepends the line with an annotation comment that stops the
message from being generated.
\li Error, warning or hint from static analysis
\endtable
\sa {Apply quick fixes}, {Refactoring}
\if defined(qtcreator)
\sa {Exclude files from to-do lists}, {Specify settings for quick fixes},
{Quick Fixes}, {C++ Quick Fixes}
\endif
*/
|