Hi

When I try to clean my combo box to add new values (may not be the same number of elements) I have a segmentation fault. It always happens on the second time where the comboBox is modified. Here's the code:

Qt Code:
  1. void MenuPrincipal::updateComboBox(std::vector<std::vector<float> > solutions)
  2. {
  3. QString solution;
  4. QList<QString> finalText;
  5. solution = " ";
  6.  
  7. ui->comboBox->clear(); //segmentation fault
  8.  
  9. //adding objects...
  10. for(int i=0;i<solutions.size();i++)
  11. {
  12. solution = "";
  13. solution.append("(");
  14. solution.append(QString::number(i+1));
  15. solution.append(")");
  16. solution.append(" -> ");
  17. for(int j=0;j<6;j++)
  18. {
  19. solution.append(QString::number((double)solutions[i][j],'f',2));
  20. if(j<solutions[i].size()-1)solution.append(" , ");
  21. }
  22. finalText.push_back(solution);
  23. }
  24.  
  25. QStringList longerList = (finalText);
  26. this->ui->comboBox->addItems(longerList);
  27. }
To copy to clipboard, switch view to plain text mode