May we see the removeRows() implementation of the model? Notice that the second parameter of QAbstractItemModel::removeRow() is parent of item being removed so for a flat model it should be an invalid index.
May we see the removeRows() implementation of the model? Notice that the second parameter of QAbstractItemModel::removeRow() is parent of item being removed so for a flat model it should be an invalid index.
J-P Nurmi
there is no removeRows implementation, that is using the thecall.Qt Code:
To copy to clipboard, switch view to plain text mode
QAbstractItemModel::removeRow() is a convenience function that further calls QAbstractItemModel::removeRows(). QAbstractItemModel::removeRows(), on the other hand, does nothing but returns false. You should provide a proper re-implementation for QAbstractItemModel::removeRows(). This includes calling QAbstractItemModel::beginRemoveRows(), modifying the internal data structure, and then calling QAbstractItemModel::endRemoveRows(). This ensures that the view gets updated correctly.
J-P Nurmi
This is for example how QStringListModel implements removeRows():
Here "lst" is the internal data structure, a QStringList.Qt Code:
{ Q_UNUSED(parent); if (count <= 0 || row < 0 || (row + count) > rowCount(parent)) return false; for (int r = 0; r < count; ++r) lst.removeAt(row); endRemoveRows(); return true; }To copy to clipboard, switch view to plain text mode
J-P Nurmi
Bookmarks