diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2017-02-01 09:16:34 +0100 |
---|---|---|
committer | Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> | 2017-03-14 16:33:59 +0000 |
commit | 29bcbeab90210da80234529905d17280374f9684 (patch) | |
tree | ab1fed93e595366130719460e961959dfd7b4f28 /src/corelib/doc/src/objectmodel | |
parent | 0c034a649f61019c16aba479fe79d20dde41f2f2 (diff) |
Deprecate QSignalMapper
Does not make much sense now that we can connect to lambda functions
[ChangeLog][QtCore][QSignalMapper] QSignalMapper is now marked
as deprecated.
Change-Id: I89135f23fdf16b42142a125eb7c9a86084c90bfc
Reviewed-by: Sze Howe Koh <szehowe.koh@gmail.com>
Diffstat (limited to 'src/corelib/doc/src/objectmodel')
-rw-r--r-- | src/corelib/doc/src/objectmodel/signalsandslots.qdoc | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/src/corelib/doc/src/objectmodel/signalsandslots.qdoc b/src/corelib/doc/src/objectmodel/signalsandslots.qdoc index ed61511c62..6d3064d217 100644 --- a/src/corelib/doc/src/objectmodel/signalsandslots.qdoc +++ b/src/corelib/doc/src/objectmodel/signalsandslots.qdoc @@ -395,24 +395,12 @@ signal, Qt provides the QObject::sender() function, which returns a pointer to the object that sent the signal. - The QSignalMapper class is provided for situations where many - signals are connected to the same slot and the slot needs to - handle each signal differently. + Lambda expressions are a convenient way to pass custom arguments to a slot: - Suppose you have three push buttons that determine which file you - will open: "Tax File", "Accounts File", or "Report File". - - In order to open the correct file, you use QSignalMapper::setMapping() to - map all the QPushButton::clicked() signals to a QSignalMapper object. Then you connect - the file's QPushButton::clicked() signal to the QSignalMapper::map() slot. - - \snippet signalmapper/filereader.cpp 0 - - Then, you connect the \l{QSignalMapper::}{mapped()} signal to - \c{readFile()} where a different file will be opened, depending on - which push button is pressed. - - \snippet signalmapper/filereader.cpp 1 + \code + connect(action, &QAction::triggered, engine, + [=]() { engine->processAction(action->text()); }); + \endcode \sa {Meta-Object System}, {Qt's Property System} |