screen capture for cannot return the checkstate of the items
I have difficulties to get the state of the checkbox. The code below that can create a clickable checkbox for me. However, I cannot read back the State of the checkbox.
void Admin_view::eq_filter_list_init()
{
no_of_col_eq=eq_db_list.size();
for(int i=0;i<no_of_col_eq;i++)
{
if(!eq_header_init)
{
std::string str = eq_db_list.value(i).toStdString();
QString eq_header=QString::fromStdString(str);
QListWidgetItem *item1 = new QListWidgetItem;
QCheckBox *check = new QCheckBox(eq_header, ui->eq_filter_list);
check->setCheckState(Qt::Checked);
//check->show();
ui->eq_filter_list->addItem(item1);
ui->eq_filter_list->setItemWidget(item1, check);
//ui->eq_filter_list->item(i)->setCheckState(Qt::Checked);
}
qDebug()<<i<<" check result:"<<item1->checkState();
qDebug()<<i<<" check result:"<<ui->eq_filter_list->item(i)->checkState();
}
}
}
To simplify the testing, I tried to printout the checkstate after I add the items. However even in line12 I have set all checkbox to checked and run the code. All the checkbox are checked, but the checkState in line 18 and 19 are also show Unchecked. And then when I uncheck some of checkbox, I also cannot read the correct checkState.