forked from qt-creator/qt-creator
Doc: Add info about supported property types
Also describe that custom properties are visible in the Properties view, where their values can be set. Change-Id: Ie82975116ae4de0ebb92050e7e2190315521ff8b Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Binary file not shown.
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 7.1 KiB |
BIN
doc/qtcreator/images/qtquick-custom-properties.png
Normal file
BIN
doc/qtcreator/images/qtquick-custom-properties.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 28 KiB |
@@ -30,8 +30,8 @@
|
|||||||
|
|
||||||
\title Specifying Dynamic Properties
|
\title Specifying Dynamic Properties
|
||||||
|
|
||||||
In addition to the properties predefined for QML types, you can specify
|
Each predefined QML type has a set of predefined properties that you can
|
||||||
\e {dynamic properties} to add properties that would not otherwise
|
specify values for. You can add custom properties that would not otherwise
|
||||||
exist for a particular type. You bind the properties to dynamic expressions
|
exist for a particular type. You bind the properties to dynamic expressions
|
||||||
to define global properties for an object that can be read by other objects.
|
to define global properties for an object that can be read by other objects.
|
||||||
For example, you can specify global properties for the root object that you
|
For example, you can specify global properties for the root object that you
|
||||||
@@ -42,18 +42,19 @@
|
|||||||
and then use bindings to refer to the value of the margin property from
|
and then use bindings to refer to the value of the margin property from
|
||||||
other objects.
|
other objects.
|
||||||
|
|
||||||
Similarly, you can add dynamic properties at component level.
|
Similarly, you can add custom properties for your own QML types that are
|
||||||
|
based on the predefined types.
|
||||||
|
|
||||||
You can specify dynamic properties for objects in the
|
You can add properties for objects in the \uicontrol Connections view,
|
||||||
\uicontrol Connections view.
|
\uicontrol Properties tab.
|
||||||
|
|
||||||
\image qmldesigner-dynamicprops.png
|
\image qmldesigner-dynamicprops.png "Custom properties in Connection View Custom Properties tab"
|
||||||
|
|
||||||
To specify dynamic properties for an object:
|
To add properties for an object:
|
||||||
|
|
||||||
\list 1
|
\list 1
|
||||||
\li In the \uicontrol {Connections} view, select the
|
\li Select \uicontrol View > \uicontrol Views >
|
||||||
\uicontrol {Properties} tab.
|
\uicontrol {Connections View} > \uicontrol {Properties}.
|
||||||
\li Select the \inlineimage plus.png
|
\li Select the \inlineimage plus.png
|
||||||
(\uicontrol Add) button to add a dynamic property for the currently
|
(\uicontrol Add) button to add a dynamic property for the currently
|
||||||
selected item. The item ID is displayed in the \uicontrol Item
|
selected item. The item ID is displayed in the \uicontrol Item
|
||||||
@@ -61,9 +62,67 @@
|
|||||||
\li Double-click the value in the \uicontrol Property column to give a
|
\li Double-click the value in the \uicontrol Property column to give a
|
||||||
name to the property.
|
name to the property.
|
||||||
\li Double-click the value in the \uicontrol {Property Type} column to
|
\li Double-click the value in the \uicontrol {Property Type} column to
|
||||||
specify the type of the property.
|
specify the \l{Supported Property Types}{type of the property}.
|
||||||
\li Double-click the value in the \uicontrol {Property Value} column
|
\li Double-click the value in the \uicontrol {Property Value} column
|
||||||
to specify a dynamic expression as the value of the property.
|
to specify the value of the property.
|
||||||
\endlist
|
\endlist
|
||||||
|
|
||||||
|
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"
|
||||||
|
|
||||||
|
For more information about setting property values in the
|
||||||
|
\uicontrol Properties view, see \l{Specifying Item Properties}.
|
||||||
|
|
||||||
|
For an example of using custom properties in an application, see
|
||||||
|
\l{Creating a Mobile Application}.
|
||||||
|
|
||||||
|
\section1 Supported Property Types
|
||||||
|
|
||||||
|
The following table describes the supported property types:
|
||||||
|
|
||||||
|
\table
|
||||||
|
\header
|
||||||
|
\li Type
|
||||||
|
\li Description
|
||||||
|
\row
|
||||||
|
\li alias
|
||||||
|
\li \l{Property Aliases}{Property alias} that holds a reference to
|
||||||
|
another property
|
||||||
|
\row
|
||||||
|
\li bool
|
||||||
|
\li Binary \c true or \c false value
|
||||||
|
\row
|
||||||
|
\li color
|
||||||
|
\li Color value that can be specified by using an SVG color name, such
|
||||||
|
as "red", "green", or "lightsteelblue", or a hexadecimal triplet or
|
||||||
|
quad in the form "#RRGGBB" and "#AARRGGBB", respectively. For
|
||||||
|
example, the color red corresponds to a triplet of "#FF0000" and
|
||||||
|
a slightly transparent blue to a quad of "#800000FF".
|
||||||
|
In addition, you can use the following Qt functions: \l{Qt::rgba()}
|
||||||
|
{Qt.rgba()}, \l{Qt::hsva()}{Qt.hsva()}, \l{Qt::hsla()}{Qt.hsla()},
|
||||||
|
\l{Qt::darker()}{Qt.darker()}, \l{Qt::lighter()}{Qt.lighter()}, and
|
||||||
|
\l{Qt::tint()}{Qt.tint()}.
|
||||||
|
\row
|
||||||
|
\li int
|
||||||
|
\li Whole integer number, such as 0, 10, or -20
|
||||||
|
\row
|
||||||
|
\li real
|
||||||
|
\li Number with a decimal point
|
||||||
|
\row
|
||||||
|
\li string
|
||||||
|
\li Free form text string
|
||||||
|
\row
|
||||||
|
\li url
|
||||||
|
\li Resource locator, such as a file name. It can be either absolute,
|
||||||
|
(\c http://qt-project.org), or relative (\c pics/logo.png). A
|
||||||
|
relative URL is resolved relative to the URL of the parent
|
||||||
|
component.
|
||||||
|
\row
|
||||||
|
\li variant
|
||||||
|
\li Generic property type. For example, variant properties can store
|
||||||
|
numbers, strings, objects, arrays, and functions.
|
||||||
|
\endtable
|
||||||
*/
|
*/
|
||||||
|
@@ -32,25 +32,30 @@
|
|||||||
|
|
||||||
The \uicontrol Properties view displays all the properties of the selected
|
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
|
item. The properties are grouped by type. The top part of the view displays
|
||||||
properties that are common to all QML types, such as position, size, and
|
properties that are common to all QML types, such as type, id, position,
|
||||||
visibility.
|
size, and visibility.
|
||||||
|
|
||||||
The bottom part of the view displays properties that are specific to each
|
The bottom part of the view displays properties that have been defined for
|
||||||
QML type. For example, the following image displays the properties you can
|
the QML type. For example, the following image displays the predefined
|
||||||
set for \uicontrol Rectangle and \uicontrol Text items.
|
properties you can set for \uicontrol Rectangle and \uicontrol Text items.
|
||||||
|
|
||||||
\image qmldesigner-element-properties.png
|
\image qmldesigner-element-properties.png
|
||||||
|
|
||||||
To change the item type, double-click the \uicontrol Type field in the
|
When you create a component using a QML type, the component has all the
|
||||||
\uicontrol Properties view, and enter the name of another QML type in the
|
properties of the type you used. If you realize later that another
|
||||||
field. If you have specified properties for the item that are not supported
|
QML type with another set of predefined properties would be more suitable
|
||||||
for the new type, the type cannot be changed and an error message is
|
for your purposes, you can change the component type by double-clicking the
|
||||||
displayed. Select the \inlineimage icons/action-icon.png
|
\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 Actions) menu next to the property name, and then select
|
||||||
\uicontrol Reset to remove the property values before trying again.
|
\uicontrol Reset to remove the property values before trying again.
|
||||||
|
|
||||||
To modify the common properties of multiple items simultaneously, select
|
To modify the values of common properties of multiple items simultaneously,
|
||||||
them in the \uicontrol Navigator or on the canvas:
|
select the items in the \uicontrol Navigator or on the canvas:
|
||||||
|
|
||||||
\list
|
\list
|
||||||
\li On Windows, press and hold \key Ctrl and \key Shift, and then click
|
\li On Windows, press and hold \key Ctrl and \key Shift, and then click
|
||||||
@@ -71,6 +76,18 @@
|
|||||||
For more information on the properties available for an item, press
|
For more information on the properties available for an item, press
|
||||||
\key {F1}.
|
\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
|
\section1 Viewing Changes in Properties
|
||||||
|
|
||||||
The default values of properties are displayed in white color, while the
|
The default values of properties are displayed in white color, while the
|
||||||
|
Reference in New Issue
Block a user