Here's the definition of a simple custom widget that has a singlesignal, \c clicked(), which is emitted with the text of the buttonthat was clicked:\snippet doc/src/snippets/qsignalmapper/buttonwidget.h 0\snippet doc/src/snippets/qsignalmapper/buttonwidget.h 1
//! [0]class ButtonWidget : public QWidget{ Q_OBJECTpublic: ButtonWidget(QStringList texts, QWidget *parent = 0);signals: void clicked(const QString &text);private: QSignalMapper *signalMapper;//! [0] //! [1]};//! [1]
snippet{3}="\dontinclude \1\n\skipline /*! [\2]\n\until /*! [\2]\n\skipline /*! [\3]\n\until /*! [\3]\n"
\snippet{signalmapper/someobject.h,0,1}
#ifndef _SOMEOBJECT_H_#define _SOMEOBJECT_H_#include <QObject>/*! [0] */class SomeObject : public QObject { Q_OBJECTpublic: SomeObject(QObject *parent):QObject(parent) {}signals: void firstSignal(); void secondSignal();/*! [0] */public slots: void emitFirstSignal(); void emitSecondSignal();};/*! [1] */#endif
class SomeObject : public QObject { Q_OBJECTpublic: SomeObject(QObject *parent):QObject(parent) {}signals: void firstSignal(); void secondSignal();};