Can u help me with this. I try to copy selected data from one QTableView to another tableview, but when i run this code my program crash.
Can u help me with this?
void Dialog:n_pushButton_clicked()
{

QAbstractItemModel * model = ui->tableView->model();
QItemSelectionModel * selection = ui->tableView->selectionModel();
QModelIndexList indexes = selection->selectedIndexes();


if(!indexes.isEmpty()){


foreach (QModelIndex i, indexes) {


qDebug()<<i.row();
qDebug()<<i.column();
ui->tableView_2->model()->setData(ui->tableView_2->model()->index(i.row(),i.column()),ui->tableView->model()->data(i).toString());

}
}
}