Connecting signals and slots with extra parameters

I have an array of TGComboBoxes, and want to do:


so that selecting item j from combobox i calls DoStuff(i,j). This seems to not work.

Is there a way of doing what I want?

(root 5.12.00, if it matters)




Slot methods can have equal or less parameters then the signal methods to which they are connected. The order and the type of slot parameters should follow those in the signal method. In spite of that restriction, there is a way of doing what you want.

  • Connect “Selected” signal to your slot method “DoStuff” having the same number/type of parameters:
  • Include in your slot method following lines in the beginning:

[code]void DoStuff(Int_t selected_cb_entry) {

TGComboBox *cb = (TGComboBox *)gTQSender;
Int_t id = cb->WidgetId();

// id contains the combobox widget id (defined in its constructor)
// sending the signal “Selected”

// then you can do:
switch (id) {


// …or if the combobox id(s) were created in order, you may use
for (Int_t i = first_one; i < last_one; i++ ) {
if(id==i) { //do something }

} // etc.


Cheers, Ilka

Thanks Ilka - it looks as though that should do what I want.