mhoover
31st August 2009, 21:05
I am using the basic QStandardItemModel to populate a QTreeView.
I have looked over all the removeRow/removeRows issues I could find on this forum, but they were not able to solve my problem.
I have been retrieving indexes to append and edit items in the QTreeView, but for some reason when I call removeRow on the this index I get bizarre behavior. I typically see nothing happen but occasionally a child node will disappear.
I have tried removing the nodes using this approach:
QModelIndex index = ui.settings_treeView->currentIndex();
QStandardItem *item = settings_model->itemFromIndex( index );
int row = settings_model->itemFromIndex( index )=>row();
settings_model->removeRow( row, index );
And I have tried this approach:
QItemSelectionModel *selection = ui.settings_treeView->selectionModel();
QModelIndex index = ui.settings_treeView->currentIndex();
settings_model->removeRows( selection->currentIndex().row(), 1, index );
But random nodes start disappearing.
This seems like something that should be easy. I'm not sure why it isn't working for me.
I have looked over all the removeRow/removeRows issues I could find on this forum, but they were not able to solve my problem.
I have been retrieving indexes to append and edit items in the QTreeView, but for some reason when I call removeRow on the this index I get bizarre behavior. I typically see nothing happen but occasionally a child node will disappear.
I have tried removing the nodes using this approach:
QModelIndex index = ui.settings_treeView->currentIndex();
QStandardItem *item = settings_model->itemFromIndex( index );
int row = settings_model->itemFromIndex( index )=>row();
settings_model->removeRow( row, index );
And I have tried this approach:
QItemSelectionModel *selection = ui.settings_treeView->selectionModel();
QModelIndex index = ui.settings_treeView->currentIndex();
settings_model->removeRows( selection->currentIndex().row(), 1, index );
But random nodes start disappearing.
This seems like something that should be easy. I'm not sure why it isn't working for me.