title: How to use QSignalMapper for a list of QAction items
body: <p>I am developing a code snippet to perform similar, not identical actions when I click on the sub menu item list. Please check the attached snapshot. QSignalMapper is the best solution to connect multiple signals to the same slot.</p>
  
  <p><img src="https://i.stack.imgur.com/zZaXY.jpg" alt="I want to perform similar actions whenever the values in the Area Threshold sub menu are clicked"></p>
  
  <p>But I am not able to exactly place, which signal is to be called for which slot. I have read a lot of theory about QSignalMapper, </p>
  
  <pre><code>http://qt-project.org/doc/qt-4.8/qsignalmapper.html
  http://doc.qt.digia.com/qq/qq10-signalmapper.html#thesignalmapperapproach
  </code></pre>
  
  <p>even implemented their codes.
  Unlike the mentioned sample programs, my QAction objects apparently cannot be defined like we define elements inside an array, coz their names were auto-generated by the design window. 
  <img src="https://i.stack.imgur.com/u6Bj4.jpg" alt="Names of qAction objects cannot be placed in for loop as they aren&#39;t sequential per se"></p>
  
  <p>I am not able to understand, what should I place as SIGNAL here, and when should I use the setMapping function? If I use setMapping function, which parameters should I implement? 
  I am simply not getting the concept thorough, not knowing what to do, whom to ask and making the mistake in my code here. Can you please advise me what I am doing wrong?
  I checked this for reference coz he had similar issue:</p>
  
  <pre><code>https://stackoverflow.com/questions/14151443/how-to-pass-a-qstring-to-a-qt-slot-from-a-qmenu-via-qsignalmapper-or-otherwise/14157471#14157471
  </code></pre>
  
  <p>***********************************UPDATED SECTION(as of Mar 3, '14)************************************************************************</p>
  
  <p>My problem is quite similar to following question:
      <a href="https://stackoverflow.com/questions/9187538/qt-how-to-add-a-list-of-qactions-to-qmenu-and-handle-them-with-a-single-slot">How to add a list of QActions to a QMenu and handle them with a single slot?</a></p>
  
  <p>I too, tried using setData in <code>helpAction(QAction *pAction)</code>, but I am still mistaken since the only value that I get when I click on the action items in the area threshold sub menu is </p>
  
  <pre><code>0
  </code></pre>
  
  <p>So my updated question is, how to use the <code>setData(const QVariant &amp;userData)</code> to assign indices to my action items. Please advise.</p>
  
  <p>mainwindow.h</p>
  
  <pre><code>#ifndef MAINWINDOW_H
  #define MAINWINDOW_H
  
  #include &lt;QMainWindow&gt;
  #include &lt;QDebug&gt;
  #include &lt;QSignalMapper&gt;
  namespace Ui {
  class MainWindow;
  }
  
  class MainWindow : public QMainWindow
  {
      Q_OBJECT
  
  public:
      explicit MainWindow(QWidget *parent = 0);
      ~MainWindow();
      void subMenuForThresholds();
  
  private:
      Ui::MainWindow *ui;
      void createActions();
      QSignalMapper *pSignalMapper;
  
  private slots:
      void interval();
      void help();
      void helpAction(QAction *pAction);
      void setAreathreshold(int value);
  };
  
  #endif // MAINWINDOW_H
  </code></pre>
  
  <p>mainwindow.cpp</p>
  
  <pre><code>#include "mainwindow.h"
  #include "ui_mainwindow.h"
  #include "intervaldialog.h"
  #include "help.h"
  MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow)
  {
      ui-&gt;setupUi(this);
      createActions();
  }
  
  MainWindow::~MainWindow()
  {
      delete ui;
  }
  
  void MainWindow::createActions()
  {
      ui-&gt;actionInterval-&gt;setStatusTip(tr("Set the interval for capturing delta &amp; reference images"));
      connect(ui-&gt;actionInterval, SIGNAL(triggered()), this, SLOT(interval()));
  
      subMenuForThresholds();
  
      ui-&gt;menuHelp-&gt;setStatusTip(tr("help "));
  //    connect(ui-&gt;menuHelp, SIGNAL(triggered(QAction*)), this, SLOT(help()));
  }
  
  void MainWindow::subMenuForThresholds()
  {
      pSignalMapper = new QSignalMapper(this);
  //    connect(pSignalMapper, SIGNAL(mapped(int)), this, SIGNAL(/*not sure what to place here?*/);
  
  
      connect(ui-&gt;menuArea_Threshold, SIGNAL(triggered(QAction*)), this, SLOT(helpAction(QAction*)));
  
  }
  
  void MainWindow::setAreaThreshold()
  {
     qDebug()&lt;&lt;value;
  }
  
  
  void MainWindow::interval()
  {
      qDebug()&lt;&lt;"inside interval qdialog";
  
      Help help;
      help.exec();
  }
  
  void MainWindow::help()
  {
      qDebug()&lt;&lt;"inside help qdialog";
      Help help;
      help.exec();
  }
  
  void MainWindow::helpAction(QAction *pAction)
  {
      ui-&gt;action25_sec-&gt;setData(10);
      int value = pAction-&gt;data().toInt();
      qDebug()&lt;&lt;value;
  }
  </code></pre>