Qt
::ItemFlags CustomModel
::flags(const QModelIndex &index
) const { if (index.column() == 16)
flags |= Qt::ItemIsUserCheckable | Qt::ItemIsEditable;
return flags;
}
{
if (index.column() == 16) {
if (role == Qt::CheckStateRole)
return (QSqlTableModel::data(index
).
toInt() != 0) ? Qt
::Checked : Qt
::Unchecked;
}
return value;
}
if(role==Qt::CheckStateRole)
}
Qt::ItemFlags CustomModel::flags(const QModelIndex &index) const {
Qt::ItemFlags flags = QSqlTableModel::flags(index);
if (index.column() == 16)
flags |= Qt::ItemIsUserCheckable | Qt::ItemIsEditable;
return flags;
}
QVariant CustomModel::data(const QModelIndex &index, int role) const
{
QVariant value = QSqlTableModel::data(index, role);
if (index.column() == 16) {
if (role == Qt::CheckStateRole)
return (QSqlTableModel::data(index).toInt() != 0) ? Qt::Checked : Qt::Unchecked;
}
return value;
}
bool CustomModel::setData(const QModelIndex &index, const QVariant &value, int role) {
if(role==Qt::CheckStateRole)
return QSqlTableModel::setData(index,value.toBool(),Qt::EditRole);
return QSqlTableModel::setData(index,value,Qt::EditRole);
}
To copy to clipboard, switch view to plain text mode
any thing you could suggest
Bookmarks