描述信號的一般化連接。 更多...
| import 語句: | import QtQml 2.15 |
Connections 對象創建到 QML 信號的連接。
When connecting to signals in QML, the usual way is to create an "on<Signal>" handler that reacts when a signal is received, like this:
MouseArea { onClicked: { foo(parameters) } }
However, it is not possible to connect to a signal in this way in some cases, such as when:
When any of these are needed, the Connections type can be used instead.
For example, the above code can be changed to use a Connections object, like this:
MouseArea { Connections { function onClicked(mouse) { foo(mouse) } } }
More generally, the Connections object can be a child of some object other than the sender of the signal:
MouseArea { id: area } // ...
Connections { target: area function onClicked(mouse) { foo(mouse) } }
另請參閱 Qt QML .
|
enabled : bool |
此特性保持項是否接受改變事件。
默認情況下,此特性為
true
.
該特性在 Qt 5.7 引入。
|
ignoreUnknownSignals : bool |
Normally, a connection to a non-existent signal produces runtime errors.
若把此特性設為
true
, such errors are ignored. This is useful if you intend to connect to different types of objects, handling a different set of signals for each object.
此特性保持發送信號的對象。
若此特性未設置,
target
默認為連接的父級。
If set to null, no connection is made and any signal handlers are ignored until the target is not null.