Re: Segmentation fault error
Code:
for (int i=0; i < obj_schedule_table->rowCount(); i++)
{
QWidget *widget1
= obj_schedule_table
->cellWidget
( i,
3 );
QComboBox *combo
= dynamic_cast<QComboBox
*>
( widget1
->children
().
at(1) );
if (combo)
{
combo->setEditable( false );
mapper->setMapping( combo, i );
connect(combo,
SIGNAL(activated
(QString)), mapper,
SLOT (map
()));
}
}
connect(mapper, SIGNAL(mapped(int)), this, SLOT(set_item_combobox_type(int)));
widget1->children().at(1)? Maybe widget1->children().count() < 1?
Re: Segmentation fault error
Does anybody help me what is wrong with above code.
Re: Segmentation fault error
Either widget1 or widget1->children().at(1) is an invalid pointer.
Re: Segmentation fault error
did you tried to step debug your code?
Re: Segmentation fault error
If you don't know how to use the debugger (and if you don't, how do you expect to become a good programmer?), modify your code to tell you what's wrong:
Code:
#include <QMessageBox>
if ( obj_schedule_table != 0 )
{
for(int i=0; i<obj_schedule_table->rowCount(); i++)
{
QWidget * widget1
= obj_schedule_table
->cellWidget
(i,
3);
if ( widget1 != 0 )
{
QComboBox * combo
= dynamic_cast<QComboBox
*>
(widget1
->children
().
at(1));
if ( combo != 0 )
{
combo->setEditable(false);
mapper->setMapping(combo, i);
connect(combo,
SIGNAL(activated
(QString)), mapper,
SLOT (map
()));
}
else
QMessageBox::critical( this,
"Error",
"Pointer to combo is NULL" );
}
else
QMessageBox::critical( this,
"Error",
"Pointer to widget1 is NULL" );
}
}
else
QMessageBox::critical( this,
"Error",
"Pointer to obj_schedule_table is NULL" );
connect(mapper, SIGNAL(mapped(int)), this, SLOT(set_item_combobox_type(int)));
Which message box do you see? That should give you a clue about where to look to solve the problem.