aboutsummaryrefslogtreecommitdiffstats
path: root/doc/qtcreator/src/qtquick/qtquick-connection-editor-signals.qdoc
blob: a9e221ce73e90ab76bd3cb357b027684fb2deb2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/****************************************************************************
**
** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Creator documentation.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
**
****************************************************************************/

/*!
    \contentspage {Qt Creator Manual}
    \previouspage qmldesigner-connections.html
    \page quick-signals.html
    \nextpage quick-dynamic-properties.html

    \title Connecting Objects to Signals

    To receive a notification when a particular signal is emitted for a
    particular object, the object definition should declare a signal handler
    named \e {on<Signal>} where \e {<Signal>} is the name of the signal, with
    the first letter capitalized. The signal handler should contain the
    JavaScript code to be executed when the signal handler is invoked.

    QML types have predefined signals that are emitted when users interact with
    the application. For example, the \l MouseArea type from the \l QtQuick
    module has a \c clicked signal that is emitted whenever the mouse is
    clicked within the area. Since the signal name is \c clicked, the signal
    handler for receiving this signal is named \c onClicked.

    For more information about signals and signal handlers, see
    \l{Signal and Handler Event System}.

    To access a signal outside of the object that emits it, you can use the
    \l Connections type for connecting to signals of arbitrary objects. A
    connections object can receive any signal from its specified target.
    You can connect objects to signals that are available to them in the
    \uicontrol Connections view.

    \image qmldesigner-connections.png

    To connect objects to signals:

    \list 1
        \li In the \uicontrol {Connections} view, select the
            \uicontrol {Connections} tab.
        \li Select the \inlineimage plus.png
            (\uicontrol Add) button to add a connection.
        \li Double-click the value in the \uicontrol Target column to add the
            object to connect to a signal.
        \li Double-click the value in the \uicontrol {Signal Handler} column to
            select the signal that the connection will listen to from a list of
            all signals available for the object.
        \li Double-click the value in the \uicontrol Actions column to specify
            the action to perform when the signal is emitted. You use JavaScript
            to specify the actions.
    \endlist

    \if defined(qtdesignstudio)
    For an example of connecting the \c clicked signal of a button to a
    \l{Adding States}{state}, see \l {Log In UI - Part 3}.
    \endif
*/