0

Got a QStandardItemModel on my QTableView and trying to remove all the rows in it.

I was first calling a method I created with a call to takeRow, which does not delete the object if I'm right.

What about removeRows from QAbstractItemModel? I've tried it, and as I had a signal on the model ( dataChanged ), it seems that the signal hasn't been disconnected cause I still have some error in the background like "Underlying C/C++ object has been deleted" when I try to delete, and then add some new rows.

Am I missing something here..?

Syrupsystem
  • 181
  • 1
  • 11

1 Answers1

0

Did you follow the advice on subclassing model classes? I only encountered such problems if I didn't followed the hints in the docs ;)

A removeRows() implementation must call beginRemoveRows() before the rows are removed from the data structure, and endRemoveRows() immediately afterwards.

dom0
  • 7,356
  • 3
  • 28
  • 50
  • Actually no, I'm not subclassing the model, I'm using the removeRows from QStandardItemModel... Found something that is not really "clean" I suppose : I'm setting row count to 0, and then re-set the model on the Table view... Which is sooo bad ^^ – Syrupsystem Jun 04 '13 at 06:26
  • Uhm actually removeRows should work just fine then. Could you edit your question and provide some source code? – dom0 Jun 04 '13 at 10:02