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. Jumping to a given Index in QTableView

Jumping to a given Index in QTableView

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 648 Views 1 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.
  • L Offline
    L Offline
    Laurent Schall
    wrote on last edited by
    #1

    Hello I would like to know if there is a way to jump/scroll/set the focus to a given index in a QTableView.

    I have implemented a search and replace functionality. When pushing to the "Replace & Find" button I would like the View to scroll in order to show the next item found in the table.

    If someone has an idea.

    JonBJ 1 Reply Last reply
    0
    • L Laurent Schall

      Hello I would like to know if there is a way to jump/scroll/set the focus to a given index in a QTableView.

      I have implemented a search and replace functionality. When pushing to the "Replace & Find" button I would like the View to scroll in order to show the next item found in the table.

      If someone has an idea.

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

      @Laurent-Schall
      http://doc.qt.io/qt-5/qabstractitemview.html#scrollTo

      Scrolls the view if necessary to ensure that the item at index is visible. The view will try to position the item according to the given hint.
      In the base class this is a pure virtual function.

      So you need to implement that yourself. QTableWidget does something (http://doc.qt.io/qt-5/qtablewidget.html#scrollToItem), so I imagine you need to do similar-ish (you could peek at its code) if you're using your own QTableView.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        QTableView::scrollTo is likely what you want.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        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