diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2009-12-17 12:45:41 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2009-12-17 12:45:41 (GMT) |
commit | b8a4b365b1105a742369bbaa5dc00e43914089e0 (patch) | |
tree | d17493be75f5a1f267abbf1e35ff40350bfdc796 /doc | |
parent | 5203626e26d9635ff82b5838fcd2b811361ffc0c (diff) | |
parent | 0236f6abce1d51eb5f42078b69b1d601e7224b1d (diff) | |
download | Qt-b8a4b365b1105a742369bbaa5dc00e43914089e0.zip Qt-b8a4b365b1105a742369bbaa5dc00e43914089e0.tar.gz Qt-b8a4b365b1105a742369bbaa5dc00e43914089e0.tar.bz2 |
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.6-integration
* '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-1:
doc: Added discussion on connecting signals that have default arg values.
Stack overflow when closing a Color panel in Cocoa.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/src/objectmodel/signalsandslots.qdoc | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/doc/src/objectmodel/signalsandslots.qdoc b/doc/src/objectmodel/signalsandslots.qdoc index 9515904..d5e3280 100644 --- a/doc/src/objectmodel/signalsandslots.qdoc +++ b/doc/src/objectmodel/signalsandslots.qdoc @@ -376,6 +376,45 @@ Some irrelevant member functions have been omitted from this example. + \section1 Signals And Slots With Default Arguments + + The signatures of signals and slots may contain arguments, and the + arguments can have defualt values. Consider QObject::destroyed(): + + \code + void destroyed(QObject* = 0); + \endcode + + When a QObject is deleted, it emits this QObject::destroyed() + signal. We want to catch this signal, wherever we might have a + dangling reference to the deleted QObject, so we can clean it up. + A suitable slot signature might be: + + \code + void objectDestroyed(QObject* obj = 0); + \endcode + + To connect the signal to the slot, we use QObject::connect() and + the \c{SIGNAL()} and \c{SLOT()} macros. The rule about whether to + include arguments or not in the \c{SIGNAL()} and \c{SLOT()} + macros, if the arguments have default values, is that the + signature passed to the \c{SIGNAL()} macro must \e not have fewer + arguments than the signature passed to the \c{SLOT()} macro. + + All of these would work: + \code + connect(sender, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(Qbject*))); + connect(sender, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed())); + connect(sender, SIGNAL(destroyed()), this, SLOT(objectDestroyed())); + \endcode + But this one won't work: + \code + connect(sender, SIGNAL(destroyed()), this, SLOT(objectDestroyed(QObject*))); + \endcode + + ...because the slot will be expecting a QObject that the signal + will not send. This connection will report a runtime error. + \section1 Advanced Signals and Slots Usage For cases where you may require information on the sender of the |