PDA

View Full Version : QStandardItem remove rows and row count



mqt
5th October 2013, 11:49
After QStandardItem::removeRows() is called, the rowCount() returns the same number. How to completely eliminate rows?

wysota
5th October 2013, 12:03
Works fine for me:


#include <QStandardItemModel>
#include <QtDebug>

int main() {
QStandardItemModel model(2,1);
qDebug() << model.rowCount();
model.removeRow(0);
qDebug() << model.rowCount();
return 0;
}

Result:
2
1

mqt
5th October 2013, 14:27
Thanks for reply
I tried QStandardItem::removeRows() not QStandardItemModel::removeRow()

wysota
5th October 2013, 17:53
removeRow() calls removeRows() so this doesn't matter. Both will work.

mqt
5th October 2013, 19:02
That was a typo, I missed "s" in second. What I mean is
QStandardItem::removeRows() Vs QStandardItemModel::removeRows()
The difference is class

wysota
5th October 2013, 19:22
QStandardItem::removeRows() can only fail if you provide an invalid index of the element to be removed. Otherwise it behaves the same as the model's method (it physically removes the row from the model).