diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-05-25 20:47:06 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-05-27 08:30:53 (GMT) |
commit | 0ea19cf01e2381969a8b8ce8cdaffe9ce873d3a9 (patch) | |
tree | 366d238fbd75b808de8aa7b701351f225a7e79dc /doc | |
parent | 5e14efa547ffac5890b008ad23e9ff0bc634a3e1 (diff) | |
download | Qt-0ea19cf01e2381969a8b8ce8cdaffe9ce873d3a9.zip Qt-0ea19cf01e2381969a8b8ce8cdaffe9ce873d3a9.tar.gz Qt-0ea19cf01e2381969a8b8ce8cdaffe9ce873d3a9.tar.bz2 |
Add a flag that ensure that a connection is made only one
It is often desirable, when doing connection, to ensure that the same
connection is only made once. This can be done with the
Qt::UniqueConnection 'flag'
Also documented the order the slot are called
Reviewed-by: Brad
Diffstat (limited to 'doc')
-rw-r--r-- | doc/src/qnamespace.qdoc | 4 | ||||
-rw-r--r-- | doc/src/signalsandslots.qdoc | 14 |
2 files changed, 13 insertions, 5 deletions
diff --git a/doc/src/qnamespace.qdoc b/doc/src/qnamespace.qdoc index fc4310b..069541f 100644 --- a/doc/src/qnamespace.qdoc +++ b/doc/src/qnamespace.qdoc @@ -528,6 +528,10 @@ Qt::DirectConnection; otherwise the signal is queued, as with Qt::QueuedConnection. + \value UniqueConnection Same as AutoConnection, but there will be a check that the signal is + not already connected to the same slot before connecting, otherwise, + the connection will fail. + \since 4.6 With queued connections, the parameters must be of types that are known to Qt's meta-object system, because Qt needs to copy the arguments to store them diff --git a/doc/src/signalsandslots.qdoc b/doc/src/signalsandslots.qdoc index 5432bd4..29c8215 100644 --- a/doc/src/signalsandslots.qdoc +++ b/doc/src/signalsandslots.qdoc @@ -178,9 +178,13 @@ looping in the case of cyclic connections (e.g., if \c{b.valueChanged()} were connected to \c{a.setValue()}). - A signal is emitted for every connection you make; if you - duplicate a connection, two signals will be emitted. You can - always break a connection using QObject::disconnect(). + By default, for every connection you make, a signal is emitted; + two signals are emitted for duplicate connections. You can break + all of these connections with a single disconnect() call. + If you pass the Qt::UniqueConnection \a type, the connection will only + be made if it is not a duplicate. If there is already a duplicate + (exact same signal to the exact same slot on the same objects), + the connection will fail and connect will return false This example illustrates that objects can work together without needing to know any information about each other. To enable this, the objects only @@ -218,8 +222,8 @@ will continue immediately, and the slots will be executed later. If several slots are connected to one signal, the slots will be - executed one after the other, in an arbitrary order, when the signal - is emitted. + executed one after the other, in the order they have been connected, + when the signal is emitted. Signals are automatically generated by the \l moc and must not be implemented in the \c .cpp file. They can never have return types |