Hi, everyone again!
I have no idea why, but when i am trying to use QSqlTableModel::removeRow(int numb) method, i’ve got deleted all records with same fields instead of deleting only 1 of them.
I am using QSQLITE Database.
All records adds via “INSERT INTO …” query.
Here are 3 screenshots of this process:
1)
2)
3)
bool MyDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index)
{
if((event->type() == QEvent::MouseButtonPress) && (dynamic_cast<QMouseEvent*>(event)->button() == Qt::LeftButton))
{
model->removeRow(index.row());
qDebug()<<"Row removed. "<<model->rowCount()<<"row(s) stayed.";
return true;
}
else
return QItemDelegate::editorEvent(event, model, option, index);
}
I have traced via qDebug(), that the removeRow() method has called only once… But it is still few records deleted, if theirs fields are same.
What i am doing wrong?
↧