Re: Locating QTableView row
You could also try if QAbstractItemView::scrollToBottom works for you.
How are you adding data from database ? Is it model or what ??
Re: Locating QTableView row
Data is already in the database. Yes, there is a model and a view.
When the user enters a field and clicks a button in the mainwindow, the slot function finds the correct database record. Then it would be nice to have the view scroll to that record.
The question is, knowing the correct database record, how to find it by index in the view?
Re: Locating QTableView row
Dont you have the index from the model ?? Same will be used for view
Re: Locating QTableView row
That would be the thing... If I had it.
From the doc, it looks like this would work:
Code:
view->selectRow(idx);
But I don't understand what the item is. How does this relate to the record data?
Re: Locating QTableView row
Did you come across QAbstractItemModel::index ?
Quote:
When the user enters a field and clicks a button in the mainwindow, the slot function finds the correct database record
Can you show the relevant code how you find the record from the model ? Because cant tell exactly without knowing what you are doing,, Let us know how you are using the model, how you are finding the item.
Re: Locating QTableView row
Thanks for your help. I got it working by selecting the id value (primary key) from the desired row, then
Code:
view->selectRow(id-1);