PDA

View Full Version : removeRow or takeRow in QStandardItemModel



arcull
27th August 2015, 08:30
Hi.
I've got a simple QTableView diplaying plain records (no tree). When I delete row should I use removeRow or takeRow, I'm a bit confused which to use, but the both seem to do the job. Thanks.

prasad_N
27th August 2015, 09:45
You might be using QStandardItemModel.

removeRow() just removes the row & returns true if successes & model will delete this row items from memory (model will take ownership & deletes the items).
takeRow() will remove all the items in row from model & returns that list of items. these list of items will not get deleted from memory (model releases the ownership with the items).

arcull
27th August 2015, 10:14
You might be using QStandardItemModel.

removeRow() just removes the row & returns true if successes & model will delete this row items from memory (model will take ownership & deletes the items).
takeRow() will remove all the items in row from model & returns that list of items. these list of items will not get deleted from memory (model releases the ownership with the items). Ok thanks, so removeRow will be appropriate in my case.