Qt Creator Manual | Managing C++ Backend Objects

Qt Creator Manual 4.11.0

Adding Bindings Between Properties ◦ Adding States

# Managing C++ Backend Objects

Many applications provide QObject objects implemented in C++ that work as a bridge between QML and C++. Such objects are typically registered with `qmlRegisterType` or `qmlRegisterSingletonType` and then used by QML to communicate with the C++ backend. Another example of such objects are the state machines created by the Qt SCXML Compiler.

Backend objects in a QML file are accessible if the QML file contains the required imports. In addition, for a non-singleton QObject, a dynamic property that contains the QObject must be specified.

A local QObject is instantiated in the current .qml file, as follows:

      property MyType myType: MyType {}.

Otherwise the property is just defined, as follows:

      property MyType myType

To manage backend objects:

1. In the Connections view, select the Backends tab to view accessible backend objects.

2. Select the (Add) button to add a backend object in the Add New C++ Backend dialog.
3. In the Type field, select the type of the backend QObject to add.
4. Select the Define object locally check box if the QObject is not registered as a singleton.
5. Select OK to add the required import and to create the property for a non-singleton object.