-1

I'm trying to find the row where a value is stock in a QTableView.

I had use QString select = ui->tableView->model()->index(row,0).data().toString(); to collect the value. Now i want the exact opposite, like an indexOf() but i can't find it in the documentation.

mip
  • 8,355
  • 6
  • 53
  • 72
Nakila_br
  • 5
  • 3
  • 2
    Did you try `QAbstractItemModel::match()` function? – vahancho Nov 22 '19 at 09:45
  • Finally i make this `int row=-1; for (int var = 0; var < ui->tableView->model()->rowCount(); ++var) { if(ui->tableView->model()->index(row,0).data().toString()==file){ row=var; } }` Thanks @vahancho – Nakila_br Nov 22 '19 at 10:10
  • @Nakila_br Please create an answer, when you found the answer yourself. It may be useful for people with the same problem and is much clearer than just a comment. – m7913d Nov 22 '19 at 16:24

1 Answers1

-1

Finally i make this

foreach(QString file, listFile) {
    int row=-1;
    for (int var = 0; var < ui->tableView->model()->rowCount(); ++var) {
        if(ui->tableView->model()->index(row,0).data().toString()==file){
           row=var;
        }
    }
Nakila_br
  • 5
  • 3