<class name="QSignalMapper" doc="/** <p>The <a href="QSignalMapper.html#QSignalMapper(com.trolltech.qt.core.QObject)"><tt>QSignalMapper</tt></a> class bundles signals from identifiable senders.</p> <p>This class collects a set of parameterless signals, and re-emits them with integer, string or widget parameters corresponding to the object that sent the signal.</p> <p>The class supports the mapping of particular strings or integers with particular objects using <a href="QSignalMapper.html#setMapping(com.trolltech.qt.core.QObject, int)"><tt>setMapping</tt></a>. The objects' signals can then be connected to the <a href="QSignalMapper.html#map(com.trolltech.qt.core.QObject)"><tt>map</tt></a> slot which will emit the mapped() signal with the string or integer associated with the original signalling object. Mappings can be removed later using <a href="QSignalMapper.html#removeMappings(com.trolltech.qt.core.QObject)"><tt>removeMappings</tt></a>.</p> <p>Example: Suppose we want to create a custom widget that contains a group of buttons (like a tool palette). One approach is to connect each button's <tt>clicked()</tt> signal to its own custom slot; but in this example we want to connect all the buttons to a single slot and parameterize the slot by the button that was clicked.</p> <p>Here's the definition of a simple custom widget that has a single signal, <tt>clicked()</tt>, which is emitted with the text of the button that was clicked:</p> <pre> class ButtonWidget : public QWidget { Q_OBJECT public: ButtonWidget(QStringList texts, QWidget *parent = 0); signals: void clicked(const QString &amp;text); private: QSignalMapper *signalMapper; };</pre> <p>The only function that we need to implement is the constructor:</p> <pre> ButtonWidget::ButtonWidget(QStringList texts, QWidget *parent) : QWidget(parent) { signalMapper = new QSignalMapper(this); QGridLayout *gridLayout = new QGridLayout; for (int i = 0; i &lt; texts.size(); ++i) { QPushButton *button = new QPushButton(texts[i]); connect(button, SIGNAL(clicked()), signalMapper, SLOT(map())); signalMapper-&gt;setMapping(button, texts[i]); gridLayout-&gt;addWidget(button, i / 3, i % 3); } connect(signalMapper, SIGNAL(mapped(const QString &amp;)), this, SIGNAL(clicked(const QString &amp;))); setLayout(gridLayout); }</pre> <p>A list of texts is passed to the constructor. A signal mapper is constructed and for each text in the list a <a href="%2E%2E/gui/QPushButton.html"><tt>QPushButton</tt></a> is created. We connect each button's <tt>clicked()</tt> signal to the signal mapper's <a href="QSignalMapper.html#map(com.trolltech.qt.core.QObject)"><tt>map</tt></a> slot, and create a mapping in the signal mapper from each button to the button's text. Finally we connect the signal mapper's mapped() signal to the custom widget's <tt>clicked()</tt> signal. When the user clicks a button, the custom widget will emit a single <tt>clicked()</tt> signal whose argument is the text of the button the user clicked.</p> @see <a href="QObject.html#QObject(com.trolltech.qt.core.QObject)"><tt>QObject</tt></a> @see <a href="%2E%2E/gui/QButtonGroup.html"><tt>QButtonGroup</tt></a> @see <a href="%2E%2E/gui/QActionGroup.html"><tt>QActionGroup</tt></a> */"> <signal name="protected final void mappedQWidget(com.trolltech.qt.gui.QWidget arg__1)" doc="/** <p>This signal is emitted when <a href="QSignalMapper.html#map(com.trolltech.qt.core.QObject)"><tt>map</tt></a> is signalled from an object that has a widget mapping set. The object's mapped widget is passed in <tt>arg__1</tt>.</p> <dl> <dt><b>Compatible Slot Signatures:</b></dt> <dd><tt>void mySlot(com.trolltech.qt.gui.QWidget arg__1)</tt></dd> <dd><tt>void mySlot()</tt></dd> </dl> <dl> <dt><b>See Also:</b></dt> <dd><a href="QSignalMapper.html#setMapping(com.trolltech.qt.core.QObject, int)"><tt>setMapping</tt></a></dd> </dl> */"/> <signal name="protected final void mappedQObject(com.trolltech.qt.core.QObject arg__1)" doc="/** <p>This signal is emitted when <a href="QSignalMapper.html#map(com.trolltech.qt.core.QObject)"><tt>map</tt></a> is signalled from an object that has an object mapping set. The object provided by the map is passed in <tt>arg__1</tt>.</p> <dl> <dt><b>Compatible Slot Signatures:</b></dt> <dd><tt>void mySlot(com.trolltech.qt.core.QObject arg__1)</tt></dd> <dd><tt>void mySlot()</tt></dd> </dl> <dl> <dt><b>See Also:</b></dt> <dd><a href="QSignalMapper.html#setMapping(com.trolltech.qt.core.QObject, int)"><tt>setMapping</tt></a></dd> </dl> */"/> <signal name="protected final void mappedString(java.lang.String arg__1)" doc="/** <p>This signal is emitted when <a href="QSignalMapper.html#map(com.trolltech.qt.core.QObject)"><tt>map</tt></a> is signalled from an object that has a string mapping set. The object's mapped string is passed in <tt>arg__1</tt>.</p> <dl> <dt><b>Compatible Slot Signatures:</b></dt> <dd><tt>void mySlot(java.lang.String arg__1)</tt></dd> <dd><tt>void mySlot()</tt></dd> </dl> <dl> <dt><b>See Also:</b></dt> <dd><a href="QSignalMapper.html#setMapping(com.trolltech.qt.core.QObject, int)"><tt>setMapping</tt></a></dd> </dl> */"/> <signal name="protected final void mappedInteger(int arg__1)" doc="/** <p>This signal is emitted when <a href="QSignalMapper.html#map(com.trolltech.qt.core.QObject)"><tt>map</tt></a> is signalled from an object that has an integer mapping set. The object's mapped integer is passed in <tt>arg__1</tt>.</p> <dl> <dt><b>Compatible Slot Signatures:</b></dt> <dd><tt>void mySlot(int arg__1)</tt></dd> <dd><tt>void mySlot()</tt></dd> </dl> <dl> <dt><b>See Also:</b></dt> <dd><a href="QSignalMapper.html#setMapping(com.trolltech.qt.core.QObject, int)"><tt>setMapping</tt></a></dd> </dl> */"/> <method name="public QSignalMapper(com.trolltech.qt.core.QObject parent)" doc="/** <p>Constructs a <a href="QSignalMapper.html#QSignalMapper(com.trolltech.qt.core.QObject)"><tt>QSignalMapper</tt></a> with parent <tt>parent</tt>.</p> */"/> <method name="public QSignalMapper()" doc="/** <p>Equivalent to <a href="QSignalMapper.html#QSignalMapper(com.trolltech.qt.core.QObject)"><tt>QSignalMapper</tt></a>(0). */"/> <method name="public final void map()" doc="/** <p>This slot emits signals based on which object sends signals to it.</p> */"/> <method name="public final void map(com.trolltech.qt.core.QObject sender)" doc="/** <p>This slot emits signals based on the <tt>sender</tt> object.</p> */"/> <method name="public final com.trolltech.qt.core.QObject mapping(java.lang.String text)"/> <method name="public final com.trolltech.qt.core.QObject mapping(com.trolltech.qt.gui.QWidget widget)" doc="/** <p>Returns the sender <a href="QObject.html#QObject(com.trolltech.qt.core.QObject)"><tt>QObject</tt></a> that is associated with the given <tt>widget</tt>.</p> */"/> <method name="public final com.trolltech.qt.core.QObject mapping(com.trolltech.qt.core.QObject object)" doc="/** <p>Returns the sender <a href="QObject.html#QObject(com.trolltech.qt.core.QObject)"><tt>QObject</tt></a> that is associated with the given <tt>object</tt>.</p> */"/> <method name="public final com.trolltech.qt.core.QObject mapping(int id)" doc="/** <p>Returns the sender <a href="QObject.html#QObject(com.trolltech.qt.core.QObject)"><tt>QObject</tt></a> that is associated with the given <tt>id</tt>.</p> @see <a href="QSignalMapper.html#setMapping(com.trolltech.qt.core.QObject, int)"><tt>setMapping</tt></a> */"/> <method name="public final void removeMappings(com.trolltech.qt.core.QObject sender)" doc="/** <p>Removes all mappings for <tt>sender</tt>.</p> <p>This is done automatically when mapped objects are destroyed.</p> */"/> <method name="public final void setMapping(com.trolltech.qt.core.QObject sender, com.trolltech.qt.core.QObject object)" doc="/** <p>Adds a mapping so that when <a href="QSignalMapper.html#map(com.trolltech.qt.core.QObject)"><tt>map</tt></a> is signalled from the given <tt>sender</tt>, the signal mapped(<tt>object</tt> ) is emitted.</p> <p>There may be at most one object for each sender.</p> */"/> <method name="public final void setMapping(com.trolltech.qt.core.QObject sender, java.lang.String text)" doc="/** <p>Adds a mapping so that when <a href="QSignalMapper.html#map(com.trolltech.qt.core.QObject)"><tt>map</tt></a> is signalled from the given <tt>sender</tt>, the signal mapped(<tt>text</tt> ) is emitted.</p> <p>There may be at most one text for each sender.</p> */"/> <method name="public final void setMapping(com.trolltech.qt.core.QObject sender, com.trolltech.qt.gui.QWidget widget)" doc="/** <p>Adds a mapping so that when <a href="QSignalMapper.html#map(com.trolltech.qt.core.QObject)"><tt>map</tt></a> is signalled from the given <tt>sender</tt>, the signal mapped(<tt>widget</tt> ) is emitted.</p> <p>There may be at most one widget for each sender.</p> */"/> <method name="public final void setMapping(com.trolltech.qt.core.QObject sender, int id)" doc="/** <p>Adds a mapping so that when <a href="QSignalMapper.html#map(com.trolltech.qt.core.QObject)"><tt>map</tt></a> is signalled from the given <tt>sender</tt>, the signal mapped(<tt>id</tt>) is emitted.</p> <p>There may be at most one integer ID for each sender.</p> @see <a href="QSignalMapper.html#mapping(int)"><tt>mapping</tt></a> */"/> </class>