Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. TableView in QML jump scroll to top every time when QSqlQueryModel updated (setQuery)

TableView in QML jump scroll to top every time when QSqlQueryModel updated (setQuery)

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 2.0k Views 2 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.
  • uralbashU Offline
    uralbashU Offline
    uralbash
    wrote on last edited by uralbash
    #1

    I have created an example where the TableView is updated through QSqlQueryModel every 2 sec and each time scroll is jump top of window. How can I keep scrollbar position after the update model?

    example https://github.com/uralbash/qml_tableview_bug

    p3c0P 1 Reply Last reply
    0
    • uralbashU uralbash

      I have created an example where the TableView is updated through QSqlQueryModel every 2 sec and each time scroll is jump top of window. How can I keep scrollbar position after the update model?

      example https://github.com/uralbash/qml_tableview_bug

      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi @uralbash,

      Since setQuery resets the model the view and thus the scroll also resets.
      You can use positionViewAtRow to scroll to a particular row.

      157

      uralbashU 1 Reply Last reply
      0
      • p3c0P p3c0

        Hi @uralbash,

        Since setQuery resets the model the view and thus the scroll also resets.
        You can use positionViewAtRow to scroll to a particular row.

        uralbashU Offline
        uralbashU Offline
        uralbash
        wrote on last edited by uralbash
        #3

        Thanks @p3c0,

        I think that's pretty classic task, typically table does not change scrollbar position when data updated. Could you give an example of how I can do it. What events can I use for positionViewAtRow function and how I can know which row is equivalent of last position? As far as I remember QTableView doesn’t change scroll position.

        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