Cucus
11th July 2011, 21:50
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:
void MenuPrincipal::updateComboBox(std::vector<std::vector<float> > solutions)
{
QString solution;
QList<QString> finalText;
solution = " ";
ui->comboBox->clear(); //segmentation fault
//adding objects...
for(int i=0;i<solutions.size();i++)
{
solution = "";
solution.append("(");
solution.append(QString::number(i+1));
solution.append(")");
solution.append(" -> ");
for(int j=0;j<6;j++)
{
solution.append(QString::number((double)solutions[i][j],'f',2));
if(j<solutions[i].size()-1)solution.append(" , ");
}
finalText.push_back(solution);
}
QStringList longerList = (finalText);
this->ui->comboBox->addItems(longerList);
}
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:
void MenuPrincipal::updateComboBox(std::vector<std::vector<float> > solutions)
{
QString solution;
QList<QString> finalText;
solution = " ";
ui->comboBox->clear(); //segmentation fault
//adding objects...
for(int i=0;i<solutions.size();i++)
{
solution = "";
solution.append("(");
solution.append(QString::number(i+1));
solution.append(")");
solution.append(" -> ");
for(int j=0;j<6;j++)
{
solution.append(QString::number((double)solutions[i][j],'f',2));
if(j<solutions[i].size()-1)solution.append(" , ");
}
finalText.push_back(solution);
}
QStringList longerList = (finalText);
this->ui->comboBox->addItems(longerList);
}