C

Connections QML Type

Enables connecting a QML signal to a handler. More...

Import Statement: import QtQuick .
Since: Qt Quick Ultralite 1.0

Properties

Detailed Description

A Connections object connects a QML signal to a handler.

Usually, QML signals are connected to an "on<Signal>" handler that reacts to the signal whenever it is triggered. Like in the following example:

MouseArea {
   onClicked: { foo(parameters) }
}

However, it is not possible to use the on<Signal> handler in the following cases:

  • Adding multiple connections to the same signal
  • Creating connections outside the scope of the signal sender
  • Connecting to targets that are not defined in QML

In any of these cases, use the Connections type instead.

For example, the earlier example can be modified to use a Connections object, like this:

MouseArea {
    id: mouseArea
    Connections {
        target: mouseArea
        onClicked: { foo(parameters) }
    }
}

Generally, the Connections object can be a child of some object other than the sender of the signal:

MouseArea {
    id: area
}
// ...
Connections {
    target: area
    onClicked: { foo(parameters) }
}

Property Documentation

target : Object

This property holds the object that sends the signal.

It must be set to the target's id or the singleton object.


Available under certain Qt licenses.
Find out more.