I have got a number of QComboBox
es. 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
).
You have at least two options:
Use QObject::sender()
to get a pointer to object which emitted a signal. Please note, that it's a simple, but not recommended way (see method's documentation).
Use QSignalMapper
.