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. QSqlTableModel QTableView
Forum Update on Monday, May 27th 2025

QSqlTableModel QTableView

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 204 Views
  • 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.
  • A Offline
    A Offline
    ancient one
    wrote on last edited by
    #1

    Hi All,
    my tableview model works as it should, when I hit the add button with the code -

    void Materials::on_addRecordButton_clicked()
    {
        model->insertRow(model->rowCount());
        ui->tableView->scrollToBottom();
    }
    

    it adds a new line at the bottom of the tableview.

    now that I have added qsortfilterproxymodel to filter four columns using lineEdits - this works,
    with this in place using the addButton, it inserts the row at the top of the tableview.

    Not what I want, causes issues trying to insert data.
    I cannot find any reference online or on docs to this issue.
    is there any basic code for the row to be inserted at the bottom of the tableview.
    or is there something simple I am missing.

    Thanks in advance

    JonBJ 1 Reply Last reply
    0
    • A ancient one

      Hi All,
      my tableview model works as it should, when I hit the add button with the code -

      void Materials::on_addRecordButton_clicked()
      {
          model->insertRow(model->rowCount());
          ui->tableView->scrollToBottom();
      }
      

      it adds a new line at the bottom of the tableview.

      now that I have added qsortfilterproxymodel to filter four columns using lineEdits - this works,
      with this in place using the addButton, it inserts the row at the top of the tableview.

      Not what I want, causes issues trying to insert data.
      I cannot find any reference online or on docs to this issue.
      is there any basic code for the row to be inserted at the bottom of the tableview.
      or is there something simple I am missing.

      Thanks in advance

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @ancient-one
      Appending a row to a table does not necessarily imply that will appear at the bottom of a table view. It depends on the sorting you have enabled, which is probably connected to your interposition of a QSortFilterProxyModel. Also you can have problems if the filter excludes the new row.

      This link, https://www.qtcentre.org/threads/68391-Adding-a-new-row-with-a-QSortFilterProxyModel, is probably not the best (I don't have time), but gives you an idea of the issues. Or https://stackoverflow.com/a/12060673/489865. While you wait for someone else to give you a nutshell solution, you might Google for something like qsortproxymodel append row.

      1 Reply Last reply
      1
      • A Offline
        A Offline
        ancient one
        wrote on last edited by
        #3

        JonB,
        something to look into.
        Thanks

        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