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
();
int row = settings_model->itemFromIndex( index )=>row();
settings_model->removeRow( row, index );
QModelIndex index = ui.settings_treeView->currentIndex();
QStandardItem *item = settings_model->itemFromIndex( index );
int row = settings_model->itemFromIndex( index )=>row();
settings_model->removeRow( row, index );
To copy to clipboard, switch view to plain text mode
And I have tried this approach:
QModelIndex index
= ui.
settings_treeView->currentIndex
();
settings_model->removeRows( selection->currentIndex().row(), 1, index );
QItemSelectionModel *selection = ui.settings_treeView->selectionModel();
QModelIndex index = ui.settings_treeView->currentIndex();
settings_model->removeRows( selection->currentIndex().row(), 1, index );
To copy to clipboard, switch view to plain text mode
But random nodes start disappearing.
This seems like something that should be easy. I'm not sure why it isn't working for me.
Bookmarks