[Qt-interest] How to remove items from QSqlTableModel via QTableView

Sven Grunewaldt strayer at olle-orks.org
Sat Apr 25 17:30:46 CEST 2009


Hi,

I have a QTableView which lies on top of a QSqlTableModel and a Button 
to remove the currently selected rows. It seems that my implementation 
of the buttons function does something wrong.
Sometimes not all selected items are removed and I just can't see why, 
maybe someone finds my mistake:

void BerichteOrk::on_removeSchuleButton_clicked()
{
     const QModelIndexList tmp = 
schuleView->selectionModel()->selectedIndexes();

     foreach (QModelIndex index, tmp)
     {
         schuleModel->removeRow(index.row());
     }
}

Regards,
Sven Grunewaldt



More information about the Qt-interest-old mailing list