From 29bcbeab90210da80234529905d17280374f9684 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 1 Feb 2017 09:16:34 +0100 Subject: 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 --- .../doc/src/objectmodel/signalsandslots.qdoc | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'src/corelib/doc/src/objectmodel') 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} -- cgit v1.2.3