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 database

    i reimplemented
    bool EditableSqlModel::insertRows(int position, int rows, const QModelIndex &parent)
    beginInsertRows(parent, position, position+rows-1);

    return true;

    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 activatable

    when 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 that

    thanks in advance

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.