View Full Version : access to combobox number

14th October 2013, 11:33

I have 3 QComboBoxes:

Combo 0:
Combo 1:
Combo 2:

I have used a for loop to add them to the layout. Each comboBox has 2 items added to it. Using the connect function, when the index of the item is changed, then I call the slot function.

So far its clear. But, I would like to have access to the Combo box number as well in the slot function.

For example, when I change the index to 1 in Combo 2, then along with the index number = 1, how can I have access to the combobox number = 2 as well in the slot function?

Please guide.

14th October 2013, 13:25
Read about QObject::sender or QSignalMapper.

14th October 2013, 16:35
Or three slots that call a common private method with the combo box number as and additional argument


14th October 2013, 17:17
thanks guys for your inputs.

I have created a QComboBox subclass and appended them using QVector<>. It works as desired now.

Following document was helpful too! (for those who have similar problems)

Cheers! :-)