crash at QList<MyControls *> handling
Hello again,
i have encountered another crash at
========================================
//header
struct MyControls
{
QComboBox * my_combobox;
QCheckBox * my_checkbox;
};
private:
QList<MyControls *> my_control_list;
//cpp
MyControls mc[8];
mc[0].my_combobox = ui->comboBox1;
...
mc[7].my_combobox = ui->comboBox8;
mc[0].my_checkbox = ui->checkBox1;
...
mc[7].my_checkbox = ui->checkBox8;
my_control_list.clear();
my_control_list<<&mc[0]<<&mc[1]<<&mc[2]<<&mc[3]<<&mc[4]<<&mc[5]<<&mc[6]<<&mc[7];
if(ui->checkBox1->isChecked()) return 1;
if (! my_control_list.at(0)->my_checkbox->isChecked()) //<- crash
return 0;
========================================
regards
navid
Re: crash at QList<MyControls *> handling
as I wrote you in the other post, use QList::insert
Re: crash at QList<MyControls *> handling
it was done:
for (int i=0; i<8; i++) {mfc_labels_list.insert(i,&ml[i]);}
but till receive crash with error:
.exe exited with code -1073741819 //(0xC0000005)
It looks like it is dereferencing a pointer that is invalid
//
also as a test
qDebug("list count = %d", my_control_list.count()); //list count = 8
if (! my_control_list.at(0)->my_checkbox->isChecked()) //<- crash
if (! my_control_list.at(1)->my_checkbox->isChecked()) //<- dont crash !
if (! my_control_list.at(2)->my_checkbox->isChecked()) //<- dont crash !
if (! my_control_list.at(7)->my_checkbox->isChecked()) //<- crash
if (! my_control_list.at(8)->my_checkbox->isChecked()) //<- crash
Re: crash at QList<MyControls *> handling
for (int i=0; i<8; i++) {mfc_labels_list.insert(i,&mc[i]);}
Re: crash at QList<MyControls *> handling
sorry
for (int i=0; i<8; i++) {my_control_list.insert(i,&mc[i]);}