First, sorry with my english.
I have a QTableView with data like this..
name | sex
----------------------
Si a | M
Si b | F
Si c | F
Si d | M
Si e | F
How to get row index in QTableView from data with name="Si c" and sex="F".
First, sorry with my english.
I have a QTableView with data like this..
name | sex
----------------------
Si a | M
Si b | F
Si c | F
Si d | M
Si e | F
How to get row index in QTableView from data with name="Si c" and sex="F".
If you are using QTableView and model, I guess you need to implement a search function yourself. You can match text using models function - QAbstractItemModel::data
In case you are using QTableWidget, you can have a look at QTableWidget::findItems
Look, I need select a row in TableView. So far, I use selectRow function.
ui->tableView->selectRow(rowindex);
Now I need select row after click a pushbutton, but not know the row index. I only know, the row have data on colum name="Si c" and colomn sex="F"
What model do you use and how do you populate that model?
I use QSqlQueryModel
Qt Code:
model->setQuery("select * from test"); ui->tableView->setModel(model);To copy to clipboard, switch view to plain text mode
Bookmarks