#include <WSignalMapper>
Inherits Wt::WObject.
Inheritance diagram for Wt::WSignalMapper< T >:

Public Slots | |
| void | map () |
| Slot for connecting signals to be mapped. | |
Public Member Functions | |
| WSignalMapper (WObject *parent=0) | |
| Create a new WSignalMapper. | |
| void | setMapping (WObject *sender, const T &data) |
| Associate data with a sender. | |
| void | mapConnect (SignalBase &signal, const T &data) |
| Map a signal. | |
Public Attributes | |
| Signal< T > | mapped |
| Signal emitted in response to a signal sent to the map() slot. | |
This class is useful if you have to respond to the same signal of many objects or widgets, but need to identify the sender through some property.
For example, in the WMessageBox implementation we use a signal mapper to react to the several buttons with a single slot, and identifying each button use the WMessageBox::StandardButton enum.
The code looks like this:
WSignalMapper<StandardButton> buttonMapper_
= new WSignalMapper<StandardButton>(this);
buttonMapper_->mapped.connect(SLOT(this, WMessageBox::onButtonClick));
for (every button B) {
WPushButton *b = new WPushButton(B.text, buttonContainer_);
buttonMapper_->mapConnect(b->clicked, B.standardButton);
}
The last statement connects the mapper to the clicked signal of the button, so that any event generated is propagated to the onButtonClick(StandardButton b) method of the WMessageBox with the given B.standardButton argument.
The type T may be any type that has proper copy semantics and a default constructor.
| void Wt::WSignalMapper< T >::map | ( | ) | [slot] |
Slot for connecting signals to be mapped.
When a signal triggers the slot, the sender is identified and used to find corresponding data set with setMapping(), which is then use to propagate further in the mapped signal.
| void Wt::WSignalMapper< T >::mapConnect | ( | SignalBase & | signal, | |
| const T & | data | |||
| ) |
Map a signal.
Connect the given signal with the slot, and associate the data when it is triggered.
| void Wt::WSignalMapper< T >::setMapping | ( | WObject * | sender, | |
| const T & | data | |||
| ) |
Associate data with a sender.
Associate data with a sender, which wel emitted by the mapped signal, when the corresponding sender triggers the map() slot.
| Signal<T> Wt::WSignalMapper< T >::mapped |
Signal emitted in response to a signal sent to the map() slot.
The argument propagated is the argument set previously with setMapping().
1.4.7