title: How to pass a value with a clicked signal from a Qt PushButton?
body: <p>I have n buttons initially all labeled '0'.
  These labels, or values, will change to different integers when the program runs, for example at some point I may have: '7', '0', '2', ...</p>
  
  <p>I have a function (or slot) that takes an int as argument:</p>
  
  <pre><code>void do_stuff(int i);
  </code></pre>
  
  <p>I want to call do_stuff(x) when 'x' is pressed. That is: when whatever button is pressed, call do_stuff with that button's value.
  How can I do that? So far I have something like:</p>
  
  <pre><code>std::vector values; // keeps track of the button values
  for (int i = 0; i &lt; n; i++){
      values.push_back(0);
      QPushButton* button = new QPushButton("0");
      layout-&gt;addWidget(button);
      // next line is nonsense but gives an idea of what I want to do:
      connect(button, SIGNAL(clicked()), SLOT(do_stuff(values[i])));
  }
  </code></pre>