Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Extend editablesqlmodel example to add data to database
Qt 6.11 is out! See what's new in the release blog

Extend editablesqlmodel example to add data to database

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 867 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    denisroi
    wrote on last edited by
    #1

    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);

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

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved