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:
Qt Code:
  1. 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:

Qt Code:
  1. // this function will be called as soon as the user will use the "Population size" checkbox
  2.  
  3. void mainFrame::changePopulationSize(){
  4. if(getMode() == Recombination){
  5. PopSize = ui_inputSpinBox_PopSize->value();
  6.  
  7. // create an additional individual, if the PopSize will be incremented
  8. if (lastNrOfPop < PopSize){
  9. IndividualT<double> *individuum = new IndividualT<double>(ChromosomeT<double>(1), ChromosomeT<double>(1 ));
  10. // first get the corresponding available range, where the individuals can be placed
  11. unsigned index= objFunction;
  12. double rangex1[2] = {list_of_optProblems[index]->range_x1[0], list_of_optProblems[index]->range_x1[1]};
  13. double rangex2[2] = {list_of_optProblems[index]->range_x2[0], list_of_optProblems[index]->range_x2[1]};
  14.  
  15. (*individuum)[0].initialize(rangex1[0], rangex1[1]);
  16. (*individuum)[1].initialize(rangex2[0], rangex2[1]);
  17. (*parents).append(*individuum);
  18. }
  19.  
  20. // delete an individual, if the PopSize will be decremented
  21. else if(lastNrOfPop > PopSize){
  22. if(getMode() == Recombination){
  23. (*parents).remove(parents->size()-1);
  24. }
  25. }
  26. lastNrOfPop = PopSize;
  27. drawIndividuals(); // draw the QwtPlotMarkers, which represent the individuals
  28. }
  29. else return;
  30.  
  31. }
To copy to clipboard, switch view to plain text mode 

Can you see the reason for this strange behaviour?

best regards,

Vitali