C++ (Qt)model1->setEditStrategy(QSqlTableModel::OnManualSubmit); QModelIndexList currentSelection = ui->mytable->selectionModel()->selectedIndexes(); // model1->removeRow(currentSelection.count());//так как не то пока удаляет qDebug()<<currentSelection; qDebug()<<currentSelection.count();
(QModelIndex(11,1,0x52d8160,QSortFilterProxyModel(0x52d7c68) ) ) 1
foreach(QModelIndex i,view->selectedIndexes()) model->removeRow(i.row());
C++ (Qt)model1->removeRow(currentSelection.at(currentSelection.count()).row()); model1->submitAll();
C++ (Qt)foreach(QModelIndex i,view.selectedIndexes())
error: within this context
C++ (Qt)model1->setEditStrategy(QSqlTableModel::OnRowChange); QModelIndexList currentSelection = ui->mytable->selectionModel()->selectedIndexes(); for (int i = 0; i < currentSelection.count(); ++i) { if (currentSelection.at(i).column() != 0) continue; model1->removeRow(currentSelection.at(i).row()); } model1->submitAll(); model1->setEditStrategy(QSqlTableModel::OnRowChange);
C++ (Qt)class MainWindow : public QMainWindow{ Q_OBJECT public:QTableView view;
QTableView view;
ui->mytable
C++ (Qt)ui->mytable->
model1->setEditStrategy(QSqlTableModel::OnManualSubmitChange); QModelIndexList currentSelection = ui->mytable->selectionModel()->selectedIndexes(); model1->removeRow(currentSelection.at(currentSelection.count()-1).row()); model1->submitAll(); model1->setEditStrategy(QSqlTableModel::OnRowChange);
C++ (Qt)void MainWindow::deleterow_slot(){ model1->setEditStrategy(QSqlTableModel::OnRowChange); QModelIndexList currentSelection = ui->mytable->selectionModel()->selectedIndexes(); for (int i = 0; i < currentSelection.count()-1; ++i) { if (currentSelection.at(i).column() != 0) continue; model1->removeRow(currentSelection.at(i).row()); } model1->submitAll(); model1->setEditStrategy(QSqlTableModel::OnRowChange); qDebug()<<currentSelection; qDebug()<<currentSelection.count();}