Jumping to a given Index in QTableView
-
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.
-
@Laurent-Schall
http://doc.qt.io/qt-5/qabstractitemview.html#scrollToScrolls 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 ownQTableView
. -
Hi,
QTableView::scrollTo is likely what you want.