aboutsummaryrefslogtreecommitdiffstats
path: root/doc/qtcreator/src/qtquick/qtquick-properties.qdoc
blob: d9a274392d2748436e30d09e35fb5c658cfc363f (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
/****************************************************************************
**
** Copyright (C) 2020 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.
**
****************************************************************************/

/*!
    \page qtquick-properties.html
    \previouspage qtquick-navigator.html
    \nextpage qtquick-fonts.html

    \title Specifying Item Properties

    The \uicontrol Properties view displays all the properties of the selected
    item. The properties are grouped by type. The top part of the view displays
    properties that are common to all QML types, such as type, id, position,
    size, and visibility.

    The bottom part of the view displays properties that have been defined for
    the QML type. For example, the following image displays the predefined
    properties you can set for \uicontrol Rectangle and \uicontrol Text items.

    \image qmldesigner-element-properties.png

    When you create a component using a QML type, the component has all the
    properties of the type you used. If you realize later that another
    QML type with another set of predefined properties would be more suitable
    for your purposes, you can change the component type by double-clicking the
    \uicontrol Type field in the \uicontrol Properties view. Enter the name of
    another QML type in the field.

    If you have specified values for properties that are not supported by
    the new type, \QC offers to remove them for you. If you'd rather do
    this yourself, you can select the \inlineimage icons/action-icon.png
    (\uicontrol Actions) menu next to the property name, and then select
    \uicontrol Reset to remove the property values before trying again.

    To modify the values of common properties of multiple items simultaneously,
    select the items in the \uicontrol Navigator or on the canvas:

    \list
        \li On Windows, press and hold \key Ctrl and \key Shift, and then click
            the items to select them.
        \li On \macos, press \key Shift to select a range of items or \key Cmd
            to select multiple single items.
    \endlist

    To return an item to its implicit position after moving it, select the
    \inlineimage qtcreator-reset-position-icon.png
    (\uicontrol {Reset Position}) button on the toolbar. To return it to its
    implicit size, select \inlineimage qtcreator-reset-size-icon.png
    (\uicontrol {Reset Size}) button.

    To set the visibility of the item, select \uicontrol Edit >
    \uicontrol Visibility in the context menu.

    For more information on the properties available for an item, press
    \key {F1}.

    \section1 Specifying Custom Properties

    Each predefined QML type has a set of properties that you can extend by
    defining additional properties for your own QML components. For more
    information, see \l{Specifying Dynamic Properties}.

    The properties you add for a QML type are displayed in the
    \uicontrol Properties view when you select a component
    of that type in \uicontrol Navigator or \uicontrol {Form Editor}.

    \image qtquick-custom-properties.png "Custom properties in Properties view"

    \section1 Viewing Changes in Properties

    The default values of properties are displayed in white color, while the
    values that you specify explicitly are highlighted with blue color. In
    addition, property changes in states are highlighted with blue.

    This allows you to easily see which values are set in the UI form or QML
    file and which values are default characteristics of a QML type or a
    component.

    When editing states, you can easily see which values are explicitly set in
    the current state and which values are derived from the base state.

    The following images illustrate this. In the base state, the \uicontrol Size
    (1) and \uicontrol Colors (2) values are explicitly set and highlighted.

    \image qmldesigner-properties-explicit-base.png "Explicitly set properties"

    In \uicontrol State1, only the color (1) is explicitly set and highlighted.

    \image qmldesigner-properties-explicit-state1.png "Explicitly set properties"

    Resetting a property sets it back to the default value and removes the value
    from the UI form or QML file.

    \note As a result, all boolean values can be visualized in four different
    ways.

    For example, visibility can be visualized as follows:

    \table
        \row
            \li \image qmldesigner-boolean-true.png
            \li TRUE
            \li The QML type is visible by default. The visibility might be
                overridden by the visibility set in the base state.
        \row
            \li \image qmldesigner-boolean-true-blue.png
            \li TRUE (highlighted)
            \li The QML type is explicitly set to visible.
        \row
            \li \image qmldesigner-boolean-false.png
            \li FALSE
            \li The QML type is hidden by default. The visibility might be
                overridden by the visibility set in the base state.
        \row
            \li \image qmldesigner-boolean-false-blue.png
            \li FALSE (hightlighted)
            \li The type is explicitly set to hidden.
    \endtable

    \section1 Picking Colors

    To specify the color of the selected item in the color picker view (1),
    select the color picker icon (2) in the \uicontrol Properties view.

    \image qtquick-designer-color-picker.png "Color Picker view"

    You can use either a solid color (3) or a gradient (4). You can select the
    gradient in the \uicontrol {Gradient Picker} (5).

    The gradient stops (6) specify the color used at a given position in a
    gradient. Drag them along the slider to set their values.

    The \uicontrol Original field displays the original color of the item,
    whereas the \uicontrol New field displays the current color. The
    \uicontrol Recent field displays the colors that you have last selected.

    \section1 Picking Gradients

    The \uicontrol {Gradient Picker} enables you to specify
    \l{https://webgradients.com/}{WebGradients} for QML types
    that support \l QGradient.

    To open the \uicontrol {Gradient Picker}, select the
    \uicontrol {Gradient Picker Dialog} icon in the \uicontrol Properties view.

    \image qtquick-designer-gradient-picker.png "Gradient Picker dialog"

    To apply a gradient on the selected item, select \uicontrol Apply.

    To save a gradient in the \uicontrol {User Presets} tab, select
    \uicontrol Save.

    By default, a linear gradient (4) is used, but you can select another
    supported gradient type in the \uicontrol Properties view.

    \section1 Marking Text Items for Translation

    To support translators, mark each text item that should be translated.
    In the \uicontrol Properties view, \uicontrol Text field, select \uicontrol tr (1).

    \image qmldesigner-text-property-tr.png "Text properties"

    By default, the text string is enclosed in a \c qsTr() call.

    \image qml-translate.png "Text marked for translation"

    If you use text IDs instead of plain text, change the default call to
    \c qsTrId(). Select \uicontrol Tools > \uicontrol Options >
    \uicontrol {Qt Quick} > \uicontrol {Qt Quick Designer}, and then select the
    \uicontrol {qsTrId()} radio button in the \uicontrol Internationalization
    group. For more information about text ID based translations, see
    \l {Qt Linguist Manual: Text ID Based Translations}.

    To preserve the context when editing the text or to change the context
    by setting a binding on the text property, change the default call to
    \c qsTranslate() by selecting the \uicontrol {qsTranslate()} radio button.

    For more information, see
    \l {Internationalization and Localization with Qt Quick}.

    \if defined(qtcreator)
    When you \l{Creating Qt Quick Projects}{create a new project}, you can
    automatically generate a translation source file (TS) for one language.
    You can add other languages later by editing the project file.
    \endif

    \section1 Building Transformations on Items

    The \uicontrol Advanced tab allows you to configure advanced
    transformations, such as rotation, scale, and translation. You
    can assign any number of transformations to an item. Each
    transformation is applied in order, one at a time.

    For more information on Transform types, see \l{Transform}.

    \section1 Editing Properties Inline

    You can double-click objects on the canvas to edit their text, color,
    or source properties inline. Because you can specify several of these
    properties for some QML types, such as \l [QML]{TextEdit}{Text Edit},
    you can also right-click objects to open the inline editors from a
    context-menu.

    \image qmldesigner-inline-editing.png
*/