SignalSpy

Enables introspection of signal emission More...

Import Statement: import .
Since: Qt 4.8

Detailed Description

In the following example, a SignalSpy is installed to watch the "clicked" signal on a user-defined Button type. When the signal is emitted, the count property on the spy will be increased.

Button {
    id: button
    SignalSpy {
        id: spy
        target: button
        signalName: "clicked"
    }
    TestCase {
        name: "ButtonClick"
        function test_click() {
            compare(spy.count, 0)
            button.clicked();
            compare(spy.count, 1)
        }
    }
}

The above style of test is suitable for signals that are emitted synchronously. For asynchronous signals, the wait() method can be used to block the test until the signal occurs (or a timeout expires).

See also TestCase.