Specifying Item Properties

The 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 Rectangle and Text items.

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 Type field in the 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, Qt Creator offers to remove them for you. If you'd rather do this yourself, you can select the (Actions) menu next to the property name, and then select 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 Navigator or on the canvas:

  • On Windows, press and hold Ctrl and Shift, and then click the items to select them.
  • On macOS, press Shift to select a range of items or Cmd to select multiple single items.

To return an item to its implicit position after moving it, select the (Reset Position) button on the toolbar. To return it to its implicit size, select (Reset Size) button.

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

For more information on the properties available for an item, press F1.

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 Specifying Dynamic Properties.

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

"Custom properties in Properties view"

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 Size (1) and Colors (2) values are explicitly set and highlighted.

"Explicitly set properties"

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

"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:

TRUEThe QML type is visible by default. The visibility might be overridden by the visibility set in the base state.

TRUE (highlighted)The QML type is explicitly set to visible.

FALSEThe QML type is hidden by default. The visibility might be overridden by the visibility set in the base state.

FALSE (hightlighted)The type is explicitly set to hidden.

Picking Colors

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

"Color Picker view"

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

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

Picking Gradients

The Gradient Picker enables you to specify WebGradients for QML types that support QGradient.

To open the Gradient Picker, select the Gradient Picker Dialog icon in the Properties view.

"Gradient Picker dialog"

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

To save a gradient in the User Presets tab, select Save.

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

Marking Text Items for Translation

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

"Text properties"

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

"Text marked for translation"

If you use text IDs instead of plain text, change the default call to qsTrId(). Select Tools > Options > Qt Quick > Qt Quick Designer, and then select the qsTrId() radio button in the Internationalization group. For more information about text ID based translations, see 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 qsTranslate() by selecting the qsTranslate() radio button.

For more information, see Internationalization and Localization with Qt Quick.

When you 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.

Loading Placeholder Data

The Design mode supports views, models, and delegates, so that when you add a Grid View, List View, or Path View item, the ListModel and the delegate item are added automatically.

However, the missing context of the application presents a challenge. Specific models defined in C++ are the most obvious case. Often, the context is missing simple properties, which are either defined in C++, or in other QML files. A typical example is an item that uses the properties of its parent, such as parent.width.

Using Dummy Models

If you open a file in the Design mode that references a C++ model, you see nothing on the canvas. If the data in the model is fetched from the internet, you have no control over it. To get reliable data, dummy data was introduced.

For example, the following code snippet describes the file example.qml that contains a ListView that in turn specifies a C++ model:

ListView {
    model: dataModel
    delegate: ContactDelegate {
        name: name

Create a directory named dummydata in the root directory of the project, so that it is not deployed to the device. In the dummydata directory, create a QML file that has the same name as the value of model:


Then create the dataModel.qml file that contains the dummy data:

import QtQuick 2.0

ListModel {
     ListElement {
         name: "Ariane"
     ListElement {
         name: "Bella"
     ListElement {
         name: "Corinna"

Creating Dummy Context

The following example presents a common pattern in QML:

Item {
    width: parent.width
    height: parent.height

This works nicely for applications but the Design mode displays a zero-sized item. A parent for the opened file does not exist, because the context is missing. To get around the missing context, the idea of a dummy context is introduced. If you place a file with the same name as the application (here, example.qml) in the dummydata/context directory, you can fake a parent context:

import QtQuick 2.0
import QmlDesigner 1.0

DummyContextObject {
    parent: Item {
        width: 640
        height: 300

Building Transformations on Items

The 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 Transform.

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 Text Edit, you can also right-click objects to open the inline editors from a context-menu.

© 2020 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.