Hi everyone,
I have a set of Pushbuttons which are created dynamically in a for() loop.
The code looks like this:

Qt Code:
  1. for(int i = 0; i < 32; i++)
  2. {
  3. btn = new MyButton(QString("%1").arg(i+1), i);
  4. //Layout stuff which works...
  5.  
  6. connect(btn, SIGNAL(clicked()), this, SLOT(setLevel()));
  7. }
To copy to clipboard, switch view to plain text mode 

The MyButton class just extends the PushButtons class. The first argument is the title, the second is an index variable (just an int). What i want to do is, that when one of the 32 buttons are pressed, the setLevel() functions is being called. I want to use the index to set the level. For example when the user presses button 21, the setLevel() function sets the level to 21.

It should be something like this, which is not working, i know...
Qt Code:
  1. connect(btn, SIGNAL(clicked()), this, SLOT(setLevel(btn.index)));
To copy to clipboard, switch view to plain text mode 

How can i do this?