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. After inserting a row in a QAbstractTableModel subclass, the QTableView will not display the new record!
Forum Updated to NodeBB v4.3 + New Features

After inserting a row in a QAbstractTableModel subclass, the QTableView will not display the new record!

Scheduled Pinned Locked Moved Unsolved General and Desktop
model view prog
2 Posts 2 Posters 171 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.
  • J Offline
    J Offline
    jdent
    wrote on 6 Aug 2024, 21:34 last edited by
    #1

    The QAbstractTableModel subclass holds a vector of rows as its data source. When I insert a new row to the vector by inserting into the vector, like this:

    auto tmp = this->rows[row];
    this->rows.insert(this->rows.begin() + row, tmp);
    

    the QTableView does not display one more row!!

    I tried emitting the DataChanged() signal but no success...

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jeremy_k
      wrote on 6 Aug 2024, 22:27 last edited by jeremy_k 8 Jul 2024, 21:05
      #2

      See QAbstractItemModel - Subclassing. To add a row to an existing model, QAbstractItemModel::beginInsertRows() and endInsertRows() must be called. dataChanged() is used to announce changes to existing cells.

      Asking a question about code? http://eel.is/iso-c++/testcase/

      1 Reply Last reply
      4

      1/2

      6 Aug 2024, 21:34

      • Login

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