{
if (index.column()==5)
{
if (role==Qt::CheckStateRole)
return false;
}
else
}
{
if (index.column()==5)
{
if (role==Qt::CheckStateRole)
}
else
}
Qt
::ItemFlags MyItemModel
::flags( const QModelIndex & index
) const{
if (index.column()==5)
return Qt::ItemIsEnabled|Qt::ItemIsSelectable|Qt::ItemIsUserCheckable;
return Qt::ItemIsEditable|Qt::ItemIsEnabled|Qt::ItemIsUserCheckable|Qt::ItemIsSelectable;
}
When I add a line, I use this call
setData(model->index(0, 5), Qt::Checked,Qt::CheckStateRole);
bool MyItemModel::setData ( const QModelIndex & index, const QVariant & value, int role)
{
if (index.column()==5)
{
if (role==Qt::CheckStateRole)
return QStandardItemModel::setData(index,value,role);
return false;
}
else
return QStandardItemModel::setData(index,value,role);
}
QVariant MyItemModel::data ( const QModelIndex & index, int role ) const
{
if (index.column()==5)
{
if (role==Qt::CheckStateRole)
return QStandardItemModel::data(index,role);
return QVariant();
}
else
return QStandardItemModel::data(index,role);
}
Qt::ItemFlags MyItemModel::flags( const QModelIndex & index ) const
{
if (index.column()==5)
return Qt::ItemIsEnabled|Qt::ItemIsSelectable|Qt::ItemIsUserCheckable;
return Qt::ItemIsEditable|Qt::ItemIsEnabled|Qt::ItemIsUserCheckable|Qt::ItemIsSelectable;
}
When I add a line, I use this call
setData(model->index(0, 5), Qt::Checked,Qt::CheckStateRole);
To copy to clipboard, switch view to plain text mode
Bookmarks