Robotex
Robotex

Reputation: 1026

QAbstractItemModel: how to correctly remove item and recalculate indexes?

Never used this class before. I inherited my class from it. How to correctly remove item and recalculate indexes? What do I need send with dataChange (what arguments will be in this signal)?

Upvotes: 0

Views: 4849

Answers (1)

Marek R
Marek R

Reputation: 37597

To remove row from model:

void MyModel::operationToRemoveItemAtRow(int row) {
    beginRemoveRows(QModelIndex(), row, row); // no parent, one row to remove

    someListWhichHoldsDataForModel.removeAt(row);

    endRemoveRows();
}

See documentation or this documentation.

Upvotes: 2

Related Questions