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. QTableView && QSqlQueryModel && data update
QtWS25 Last Chance

QTableView && QSqlQueryModel && data update

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 5.4k 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.
  • L Offline
    L Offline
    luca
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • L Offline
      L Offline
      luca
      wrote on last edited by
      #2

      I finally found a solution that works fine for me:

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

      1 Reply Last reply
      0
      • J Offline
        J Offline
        JeffV
        wrote on last edited by
        #3

        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!

        1 Reply Last reply
        1

        • Login

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