Qt World Summit: Register Today!

QSqlTableModel QTableView

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

    void Materials::on_addRecordButton_clicked()

    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

  • @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.

  • JonB,
    something to look into.

Log in to reply