Extend editablesqlmodel example to add data to database
-
examples/sql/querymodel/ contains an EditableSqlModel class, the class implements updates to existing data in the underlying db
i would like also to add lines to the model that will be upon request added to databasei reimplemented
@
bool EditableSqlModel::insertRows(int position, int rows, const QModelIndex &parent)
{
beginInsertRows(parent, position, position+rows-1);endInsertRows(); return true;
}
@
and
@
Qt::ItemFlags EditableSqlModel::flags(const QModelIndex &index) const
{
if (!index.isValid())
return 0;return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}
@
but when i try to insert a line in the model the cells are not activatablewhen i try to index i get an invalid index item
should i reimplement
QModelIndex index(int row, int column, const QModelIndex &parent)?
if so how should i do thatthanks in advance