void scrollBarValueChanged(int value)
{
int row = view->rowAt(value);
}
Such as the title, when the scroll bar rolling, how to get the scroll row index?
void scrollBarValueChanged(int value)
{
int row = view->rowAt(value);
}
Such as the title, when the scroll bar rolling, how to get the scroll row index?
Use horizontalScrollBar()
verticalScrollBar()
functions and get scroll value from it.
QScrollBar *verticalScroll = ui->tableView->verticalScrollBar();
QScrollBar *horizontalScroll = ui->tableView->horizontalScrollBar();
int valueV = verticalScroll->value();
int valueH = horizontalScroll->value();
Also use scrollTo
function to scroll to your table cell index. (horizontally and vertically)
ui->tableView->scrollTo( ui->tableView->model()->index(row,column) );
like this image:
ui->tableView->scrollTo(ui->tableView->model()->index(7,3));
The QTableView page on Qt website.
Looks like rowAt and columnAt are exactly what you need.