- Qt Creator Manual
- Specifying Dynamic Properties
- Qt Creator Manual 4.15.2

Adding Bindings Between Properties ◦ Managing C++ Backend Objects

# Specifying Dynamic Properties

Each preset component has a set of preset properties that you can specify values for. You can add custom properties that would not otherwise exist for a particular component type. You bind the properties to dynamic expressions to define global properties for a component that can be read by other components. For example, you can specify global properties for the root component that you can use in the child components.

For example, to specify spacing between UI elements, you could define a margin for a component that does not have a margin property, and then use bindings to refer to the value of the margin property from other components.

Similarly, you can add custom properties for your own components that are based on preset components.

You can add properties for components in Connection View > Properties.

To add properties for a component:

1. Select View > Views > Connection View > Properties.
2. Select the (Add) button to add a dynamic property for the currently selected component. The component ID is displayed in the Item column.
3. Double-click the value in the Property column to give a name to the property. Property names must begin with a lower case letter and can only contain letters, numbers, and underscores. JavaScript reserved words are not valid property names.
4. Double-click the value in the Property Type column to specify the type of the property.
5. Double-click the value in the Property Value column to specify the value of the property.

Right-click a property and select Open Binding Editor in the context menu to bind the value of the property to that of another one or to data accessible in the application in Binding Editor. For more information, see Setting Bindings.

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

For more information about setting property values in the Properties view, see Specifying Component Properties.

For an example of using custom properties in an application, see Creating a Mobile Application.

## Supported Property Types

The following table describes the supported property types:

Type | Description
--- | ---
alias | Property alias that holds a reference to another property
bool | Binary `true` or `false` value
color | 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: Qt.rgba(), Qt.hsva(), Qt.hsla(), Qt.darker(), Qt.lighter(), and Qt.tint().
int | Whole integer number, such as 0, 10, or -20
real | Number with a decimal point
string | Free form text string
url | Resource locator, such as a file name. It can be either absolute, (`http://qt-project.org`), or relative (`pics/logo.png`). A relative URL is resolved relative to the URL of the parent component.
variant | Generic property type. For example, variant properties can store numbers, strings, objects, arrays, and functions.

Adding Bindings Between Properties ◦ Managing C++ Backend Objects