PDA

View Full Version : Get Row Index



wirasto
12th September 2009, 18:26
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".

aamer4yu
13th September 2009, 01:26
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

wirasto
13th September 2009, 03:11
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"

Lykurg
13th September 2009, 06:36
What model do you use and how do you populate that model?

wirasto
13th September 2009, 13:57
I use QSqlQueryModel



QSqlQueryModel *model=new QSqlQueryModel();
model->setQuery("select * from test");

ui->tableView->setModel(model);