Each item has a check box and this is displayed, However, I cannot make the check box change value
You need to write the checked status to the model, this should done in setData() method, I have added, it works. check this out.
bool ReportModel::setData(const QModelIndex& index, const QVariant& value, int role)
{
qDebug() << "ReportModel::setData";
if(role == Qt::CheckStateRole)
{
ReportEditorTreeItem* item = getItem(index);
if(index.column() == 0)
item->setIncluded(value.toBool());
}
emit dataChanged(index,index);
return true;
}
bool ReportModel::setData(const QModelIndex& index, const QVariant& value, int role)
{
qDebug() << "ReportModel::setData";
if(role == Qt::CheckStateRole)
{
ReportEditorTreeItem* item = getItem(index);
if(index.column() == 0)
item->setIncluded(value.toBool());
}
emit dataChanged(index,index);
return true;
}
To copy to clipboard, switch view to plain text mode
SimpleTree_1.zip
Bookmarks