poporacer
11th December 2010, 22:54
I have a stacked widget and I load classes into the stacked widget. On this form is a combo box (cmbName) that gets populated through an iteration of a database. Then there is a function call to set the currentIndex of the combobox to the index of the item with a specified id number (id from the database) I added another Qdialog and used the same code for setting the currentIndex and in this class the program crashes with a sementation fault. I searched this forum and other areas and searched my code. I could not find any of the things that were mentioned for a segmentation fault. Am I not seeing something? It looks like anytime I try to reference anything to do with the combobox I get the error. What could I be missing?
void SectionTimer::restoreName(int id)
{
if (id>=0)
{
qDebug()<<"id in section restore rider"<<id;
qDebug()<<"index in sectionTimer restore name"<<ui->cmbName->currentIndex();//this creates Segmentation fault
int index = ui->cmbName->findData(id);// if I comment out above line, this creates segmentation fault.
//qDebug()<<"index (calculated) in section restore name"<<index;
ui->cmbName->setCurrentIndex(index);
}
else
{
ui->cmbName->setCurrentIndex(0);
}
}
I use the exact same code elsewhere and there is no problem.
The id number is correct coming into the code. The index is not (there are only about 10 entries in the combobox)5592 The entry for the this pointer doesn't look correct?
void SectionTimer::restoreName(int id)
{
if (id>=0)
{
qDebug()<<"id in section restore rider"<<id;
qDebug()<<"index in sectionTimer restore name"<<ui->cmbName->currentIndex();//this creates Segmentation fault
int index = ui->cmbName->findData(id);// if I comment out above line, this creates segmentation fault.
//qDebug()<<"index (calculated) in section restore name"<<index;
ui->cmbName->setCurrentIndex(index);
}
else
{
ui->cmbName->setCurrentIndex(0);
}
}
I use the exact same code elsewhere and there is no problem.
The id number is correct coming into the code. The index is not (there are only about 10 entries in the combobox)5592 The entry for the this pointer doesn't look correct?