Hi guys,
i'm trying to get a current selected row from a tableview so i can retrieve data from database edit them and update the database.i'm using QSqlTableModel and QTableView.
When i run my application and push the editButton the application always crush,what seem to be a problem ,please help me here is the slot which cause the problem.

Qt Code:
  1. void customers::on_pushButton_2_clicked()
  2. {
  3. const QModelIndexList list = m_ui->customerView->selectionModel()->selection().indexes();
  4. for (int i = 1; i < list.count(); i++)
  5. {
  6. QModelIndex index = list.at(i);
  7. int row = index.row();
  8. rows.insert(index.row());
  9. }
  10. qDebug() << row;
  11.  
  12.  
  13.  
  14. QSqlQuery query;
  15. query.exec(QString("SELECT * FROM customer where Id = row"));
  16. while (query.next()) {
  17.  
  18. db_id = query.value(0).toInt();
  19. db_LastName = query.value(1).toString();
  20. db_FirstName = query.value(2).toString();
  21. db_Category = query.value(3).toString();
  22. db_Amount = query.value(4).toString();
  23.  
  24.  
  25.  
  26. }
  27.  
  28.  
  29. dialog = new newCustomer(this);
  30. dialog->editCustomer(db_LastName);
  31. int accepted = dialog->exec();
  32. if(accepted == 1 )
  33. {
  34.  
  35. }
  36. }
To copy to clipboard, switch view to plain text mode