Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QTableView && QSqlQueryModel && data update



  • Hi all,

    I have a QTableView and its model QSqlQueryModel to show some data from a query.

    If I update the query, the tableView automatically scroll to the first row but I need to keep the old position of the table.

    Now I'm trying to register the actual scroll position of a table and to scroll to this position after an update but it doesn't works as good as expected.

    Is there a better solution?

    Tnaks



  • I finally found a solution that works fine for me:

    @
    int last_position = tableView->verticalScrollBar()->value();
    ... some update...
    tableView->verticalScrollBar()->setValue(position);
    @



  • I finally found a solution that works fine for me:

    @
    int last_position = tableView->verticalScrollBar()->value();
    ... some update...
    tableView->verticalScrollBar()->setValue(position);
    @



  • I know this is old, but I tried a lot of things to solve this same problem without success. Your solution worked for me. Thanks!


Log in to reply