2014-12-02 16:21:54 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2020-02-26 09:36:22 +01:00
|
|
|
** Copyright (C) 2020 The Qt Company Ltd.
|
2016-01-15 14:51:16 +01:00
|
|
|
** Contact: https://www.qt.io/licensing/
|
2014-12-02 16:21:54 +01:00
|
|
|
**
|
2016-01-15 14:51:16 +01:00
|
|
|
** This file is part of the Qt Creator documentation.
|
2014-12-02 16:21:54 +01:00
|
|
|
**
|
|
|
|
|
** 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
|
2016-01-15 14:51:16 +01:00
|
|
|
** 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.
|
2014-12-02 16:21:54 +01:00
|
|
|
**
|
2016-01-15 14:51:16 +01:00
|
|
|
** 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.
|
2014-12-02 16:21:54 +01:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
/*!
|
2018-07-11 13:53:28 +02:00
|
|
|
\contentspage index.html
|
2020-02-26 09:36:22 +01:00
|
|
|
\previouspage studio-timeline.html
|
2014-12-02 16:21:54 +01:00
|
|
|
\page qmldesigner-connections.html
|
2018-07-03 11:39:35 +02:00
|
|
|
\nextpage quick-signals.html
|
2014-12-02 16:21:54 +01:00
|
|
|
|
|
|
|
|
\title Adding Connections
|
|
|
|
|
|
2018-07-03 11:39:35 +02:00
|
|
|
The user interface components and the application need to communicate with
|
|
|
|
|
each other. For example, a button needs to know that the user has clicked
|
|
|
|
|
on it. The button may then change color to indicate its state or perform an
|
|
|
|
|
action. Further, the application needs to know whether the user is clicking
|
|
|
|
|
the button, because it may need to relay this clicking event to other
|
|
|
|
|
applications.
|
|
|
|
|
|
|
|
|
|
QML has a signal and handler mechanism, that enables components to respond
|
|
|
|
|
to application events. Events are represented by \e signals. When a signal
|
|
|
|
|
is emitted, the corresponding \e {signal handler} is invoked to respond to
|
|
|
|
|
the event by using scripts or other operations placed in the handler.
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
A component's property can be assigned a static value which stays constant
|
|
|
|
|
until it is explicitly assigned a new value. However, to make the fullest
|
|
|
|
|
use of QML and its built-in support for dynamic object behaviors, most QML
|
|
|
|
|
types use property bindings. This means that you can specify relationships
|
|
|
|
|
between different object properties so that when a property's sependencies
|
|
|
|
|
change in value, the property's value is automatically updated accordingly.
|
|
|
|
|
|
|
|
|
|
Behind the scenes, the QML engine monitors the property's dependencies (that
|
|
|
|
|
is, the variables in the binding expression). When a change is detected, the
|
|
|
|
|
QML engine re-evaluates the binding expression and applies the new result to
|
|
|
|
|
the property.
|
|
|
|
|
|
|
|
|
|
The following sections describe how to use the \uicontrol {Connections} view
|
|
|
|
|
to perform the following tasks:
|
2014-12-02 16:21:54 +01:00
|
|
|
|
|
|
|
|
\list
|
2018-07-03 11:39:35 +02:00
|
|
|
\li \l{Connecting Objects to Signals}
|
|
|
|
|
\li \l{Specifying Dynamic Properties}
|
|
|
|
|
\li \l{Adding Bindings Between Properties}
|
2018-08-24 13:46:38 +02:00
|
|
|
\if defined(qtcreator)
|
2018-07-03 11:39:35 +02:00
|
|
|
\li \l{Managing C++ Backend Objects}
|
2018-08-24 13:46:38 +02:00
|
|
|
\endif
|
2014-12-02 16:21:54 +01:00
|
|
|
\endlist
|
2019-05-15 15:23:04 +02:00
|
|
|
|
|
|
|
|
For an example of using properties, bindings, and connections to create a
|
|
|
|
|
scalable push button, see \l{Creating Scalable Buttons and Borders}.
|
2014-12-02 16:21:54 +01:00
|
|
|
*/
|