Hello,
could someone of you explain me why the value of a spinBox is increased or decreased 3 times, if I only click once on it?
I have created my form with Qt Designer and then connected the SIGNAL of spinBox to the member function of this form:
connect(ui_inputSpinBox_PopSize, SIGNAL(valueChanged(int)), this , SLOT(changePopulationSize()));
connect(ui_inputSpinBox_PopSize, SIGNAL(valueChanged(int)), this , SLOT(changePopulationSize()));
To copy to clipboard, switch view to plain text mode
and the function looks like this:
// this function will be called as soon as the user will use the "Population size" checkbox
void mainFrame::changePopulationSize(){
if(getMode() == Recombination){
PopSize = ui_inputSpinBox_PopSize->value();
// create an additional individual, if the PopSize will be incremented
if (lastNrOfPop < PopSize){
IndividualT<double> *individuum = new IndividualT<double>(ChromosomeT<double>(1), ChromosomeT<double>(1 ));
// first get the corresponding available range, where the individuals can be placed
unsigned index= objFunction;
double rangex1[2] = {list_of_optProblems[index]->range_x1[0], list_of_optProblems[index]->range_x1[1]};
double rangex2[2] = {list_of_optProblems[index]->range_x2[0], list_of_optProblems[index]->range_x2[1]};
(*individuum)[0].initialize(rangex1[0], rangex1[1]);
(*individuum)[1].initialize(rangex2[0], rangex2[1]);
(*parents).append(*individuum);
}
// delete an individual, if the PopSize will be decremented
else if(lastNrOfPop > PopSize){
if(getMode() == Recombination){
(*parents).remove(parents->size()-1);
}
}
lastNrOfPop = PopSize;
drawIndividuals(); // draw the QwtPlotMarkers, which represent the individuals
}
else return;
}
// this function will be called as soon as the user will use the "Population size" checkbox
void mainFrame::changePopulationSize(){
if(getMode() == Recombination){
PopSize = ui_inputSpinBox_PopSize->value();
// create an additional individual, if the PopSize will be incremented
if (lastNrOfPop < PopSize){
IndividualT<double> *individuum = new IndividualT<double>(ChromosomeT<double>(1), ChromosomeT<double>(1 ));
// first get the corresponding available range, where the individuals can be placed
unsigned index= objFunction;
double rangex1[2] = {list_of_optProblems[index]->range_x1[0], list_of_optProblems[index]->range_x1[1]};
double rangex2[2] = {list_of_optProblems[index]->range_x2[0], list_of_optProblems[index]->range_x2[1]};
(*individuum)[0].initialize(rangex1[0], rangex1[1]);
(*individuum)[1].initialize(rangex2[0], rangex2[1]);
(*parents).append(*individuum);
}
// delete an individual, if the PopSize will be decremented
else if(lastNrOfPop > PopSize){
if(getMode() == Recombination){
(*parents).remove(parents->size()-1);
}
}
lastNrOfPop = PopSize;
drawIndividuals(); // draw the QwtPlotMarkers, which represent the individuals
}
else return;
}
To copy to clipboard, switch view to plain text mode
Can you see the reason for this strange behaviour?
best regards,
Vitali
Bookmarks