After QStandardItem::removeRows() is called, the rowCount() returns the same number. How to completely eliminate rows?
After QStandardItem::removeRows() is called, the rowCount() returns the same number. How to completely eliminate rows?
Works fine for me:
Qt Code:
#include <QStandardItemModel> #include <QtDebug> int main() { qDebug() << model.rowCount(); model.removeRow(0); qDebug() << model.rowCount(); return 0; }To copy to clipboard, switch view to plain text mode
Result:
2
1
Thanks for reply
I tried QStandardItem::removeRows() not QStandardItemModel::removeRow()
removeRow() calls removeRows() so this doesn't matter. Both will work.
That was a typo, I missed "s" in second. What I mean is
QStandardItem::removeRows() Vs QStandardItemModel::removeRows()
The difference is class
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).
mqt (7th October 2013)
Bookmarks