panoss
23rd February 2017, 08:39
I want to make a new model containing only the selected rows of this table.
Appending the selected rows to the empty model named "selected_rows_model" (QSqlTableModel).
QItemSelectionModel *selectionModel = ui.devices_finder_tbl->selectionModel();
if(selectionModel->hasSelection() ){
//QModelIndexList list = selectionModel->selectedRows();
QModelIndexList list = ui.devices_finder_tbl->selectedIndexes();
for(int i = 0; i < list.size(); i++)
{
QModelIndex index = list.at(i);
selected_rows_model->insertRow(selected_rows_model->rowCount(), index);
}
}
But it's not working, this row:
selected_rows_model->insertRow(selected_rows_model->rowCount(), index);
is wrong.
Ho can I fix it?
Appending the selected rows to the empty model named "selected_rows_model" (QSqlTableModel).
QItemSelectionModel *selectionModel = ui.devices_finder_tbl->selectionModel();
if(selectionModel->hasSelection() ){
//QModelIndexList list = selectionModel->selectedRows();
QModelIndexList list = ui.devices_finder_tbl->selectedIndexes();
for(int i = 0; i < list.size(); i++)
{
QModelIndex index = list.at(i);
selected_rows_model->insertRow(selected_rows_model->rowCount(), index);
}
}
But it's not working, this row:
selected_rows_model->insertRow(selected_rows_model->rowCount(), index);
is wrong.
Ho can I fix it?