PDA

View Full Version : crash on QTreeWidgetItem::data



waiter
1st July 2013, 10:23
TreewidgetForCheckbox::TreewidgetForCheckbox(QWidg et *parent) :
QTreeWidget(parent)
{
self_ = false;

connect(this,SIGNAL(itemChanged(QTreeWidgetItem*,i nt)),
this,SLOT(OnItemChanged(QTreeWidgetItem*,int)));

}

void TreewidgetForCheckbox::OnItemChanged(QTreeWidgetIt em *Aitem, int )
{

if(self_ == true)
return;
QTreeWidgetItem *parentItem = Aitem->parent();
int itemstat = Aitem->data(0,Qt::CheckStateRole).toInt();
if(itemstat ==Qt::PartiallyChecked)
{}
}

why it crash int itemstat = Aitem->data(0,Qt::CheckStateRole).toInt() ???
}

Santosh Reddy
1st July 2013, 11:48
Are you sure?

ChrisW67
1st July 2013, 13:33
AItem is null or invalid and it is possibly crashing on the line before.
The item has no column 0, i.e. it was constructed with an empty QStringList.