70 }; |
70 }; |
71 |
71 |
72 /*! |
72 /*! |
73 \qmlclass Connections QDeclarativeConnections |
73 \qmlclass Connections QDeclarativeConnections |
74 \since 4.7 |
74 \since 4.7 |
75 \brief A Connections object describes generalized connections to signals. |
75 \brief A Connections element describes generalized connections to signals. |
|
76 |
|
77 A Connections object creates a connection to a QML signal. |
76 |
78 |
77 When connecting to signals in QML, the usual way is to create an |
79 When connecting to signals in QML, the usual way is to create an |
78 "on<Signal>" handler that reacts when a signal is received, like this: |
80 "on<Signal>" handler that reacts when a signal is received, like this: |
79 |
81 |
80 \qml |
82 \qml |
81 MouseArea { |
83 MouseArea { |
82 onClicked: { foo(...) } |
84 onClicked: { foo(...) } |
83 } |
85 } |
84 \endqml |
86 \endqml |
85 |
87 |
86 However, in some cases, it is not possible to connect to a signal in this |
88 However, it is not possible to connect to a signal in this way in some |
87 way, such as: |
89 cases, such as when: |
88 |
90 |
89 \list |
91 \list |
90 \i multiple connections to the same signal |
92 \i Multiple connections to the same signal are required |
91 \i connections outside the scope of the signal sender |
93 \i Creating connections outside the scope of the signal sender |
92 \i connections to targets not defined in QML |
94 \i Connecting to targets not defined in QML |
93 \endlist |
95 \endlist |
94 |
96 |
95 When any of these are needed, the Connections object can be used instead. |
97 When any of these are needed, the Connections element can be used instead. |
96 |
98 |
97 For example, the above code can be changed to use a Connections object, |
99 For example, the above code can be changed to use a Connections object, |
98 like this: |
100 like this: |
99 |
101 |
100 \qml |
102 \qml |
139 |
141 |
140 /*! |
142 /*! |
141 \qmlproperty Object Connections::target |
143 \qmlproperty Object Connections::target |
142 This property holds the object that sends the signal. |
144 This property holds the object that sends the signal. |
143 |
145 |
144 If not set at all, the target defaults to be the parent of the Connections. |
146 If this property is not set, the \c target defaults to the parent of the Connection. |
145 |
147 |
146 If set to null, no connection is made and any signal handlers are ignored |
148 If set to null, no connection is made and any signal handlers are ignored |
147 until the target is not null. |
149 until the target is not null. |
148 */ |
150 */ |
149 QObject *QDeclarativeConnections::target() const |
151 QObject *QDeclarativeConnections::target() const |
173 } |
175 } |
174 |
176 |
175 /*! |
177 /*! |
176 \qmlproperty bool Connections::ignoreUnknownSignals |
178 \qmlproperty bool Connections::ignoreUnknownSignals |
177 |
179 |
178 Normally, you will get a runtime error if you try to connect |
180 Normally, a connection to a non-existent signal produces runtime errors. |
179 to signals on an object which the object does not have. |
181 |
180 |
182 If this property is set to \c true, such errors are ignored. |
181 By setting this flag to true, such errors are ignored. This is |
183 This is useful if you intend to connect to different types of objects, handling |
182 useful if you intend to connect to different types of object, handling |
184 a different set of signals for each object. |
183 a different set of signals for each. |
|
184 */ |
185 */ |
185 bool QDeclarativeConnections::ignoreUnknownSignals() const |
186 bool QDeclarativeConnections::ignoreUnknownSignals() const |
186 { |
187 { |
187 Q_D(const QDeclarativeConnections); |
188 Q_D(const QDeclarativeConnections); |
188 return d->ignoreUnknownSignals; |
189 return d->ignoreUnknownSignals; |