summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@qt.io>2018-07-10 15:36:40 +0200
committerPaul Wicking <paul.wicking@qt.io>2018-07-16 07:57:55 +0000
commit40a98ea750b90e453f552a1d1eb46b9947c951fa (patch)
tree9300c26ea7650ba4938bcd637711c9fc0db70f32
parent582d221b29bbf7f90d9dc07ab3efa4df089160d7 (diff)
Use context when connecting to functors in docs
This is the introduction text to signals and slots and should rather show best practices. Using context is generally advisable to have life-time of connections under control. Change-Id: I213b13d978a38e13834cdbccf1bea06d53ba8320 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r--src/corelib/doc/src/objectmodel/signalsandslots.qdoc4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/corelib/doc/src/objectmodel/signalsandslots.qdoc b/src/corelib/doc/src/objectmodel/signalsandslots.qdoc
index 6d3064d217..0cbbef0502 100644
--- a/src/corelib/doc/src/objectmodel/signalsandslots.qdoc
+++ b/src/corelib/doc/src/objectmodel/signalsandslots.qdoc
@@ -361,9 +361,11 @@
You can also connect to functors or C++11 lambdas:
\code
- connect(sender, &QObject::destroyed, [=](){ this->m_objects.remove(sender); });
+ connect(sender, &QObject::destroyed, context, [=](){ this->m_objects.remove(sender); });
\endcode
+ The lambda will be disconnected when the context is destroyed.
+
The other way to connect a signal to a slot is to use QObject::connect()
and the \c{SIGNAL} and \c{SLOT} macros.
The rule about whether to