qt

How to forbid equal indexes in QComboBoxes


I have got a number of QComboBoxes. Suppose that we have one combobox with index i and another combobox with index j. If user activate index j in the first combobox I want the second combobox index to be changed to i, so that there no equal indexes in all comboboxes. What is the easiest way to do it? I have tryed to do it with SIGNALS AND SLOTS approach:

    for(int i=0;i<boxes.size();++i){
    connect(boxes[i], SIGNAL(activated(int)),this,SLOT(boxIndexChanged(int)));
}

where boxes is a QList<QComboBox*> the problem here is that i don't know in slot function boxIndexChanged(int index) which combobox have emited signal(I need it in the case if there are identical indexes in two combobox).


Solution

  • You have at least two options: