You need to write the checked status to the model, this should done in setData() method, check this out..
1. Save the checked status of item in your model (to be done in setData())
2. Send it back to the view when requested (to be done in data())
{
if(index.column() == 0 && role == Qt::CheckStateRole)
{
// return the state saved in setData (refer setData())
}
}
bool q::setData(const QModelIndex& index, const QVariant& value, int role)
{
if(role == Qt::CheckStateRole)
{
// Set the checked status internally in your model
}
emit dataChanged(index,index);
return true;
}
QVariant q::data(const QModelIndex &index, int role) const
{
if(index.column() == 0 && role == Qt::CheckStateRole)
{
// return the state saved in setData (refer setData())
}
return QVariant();
}
bool q::setData(const QModelIndex& index, const QVariant& value, int role)
{
if(role == Qt::CheckStateRole)
{
// Set the checked status internally in your model
}
emit dataChanged(index,index);
return true;
}
To copy to clipboard, switch view to plain text mode
Bookmarks