Support #957
closedModify node in wtreeview
0%
Description
Hi,
How can i modify the content of a wtreeview node selected node ( by selectedIndexes().begin()) , after that the node is displayed without remove and re-insert the node in a structure like that is used in treeview example ?
Thanks, Francesco.
Updated by Francesco Alfano over 13 years ago
The the node to be modified is identified by
"WModelIndex selected = *treeView_->selectedIndexes().begin()"
where treeView_ is a WTreeView.
If I cannot change it, how can I remove it?
Updated by Koen Deforche over 13 years ago
- Status changed from New to Feedback
- Assignee set to Koen Deforche
Hey Fransesco,
Given the index, you modify the underlying model at that index, and this will be automatically reflected in the view.
All changes should be made on the model.
You can use the WAbstractItemModel API to make the changes (which has as benefit that it will work with any concrete model implementation), or you can use the API of the specific model you are using, e.g. WStandardItemModel API, which is more convenient.
Regards,
koen
Updated by Francesco Alfano over 13 years ago
Thanks, for your response.
Could you give me an example code ?
how can i remove that node ?
Thanks, Francesco
Updated by Koen Deforche over 13 years ago
Hey Fransesco,
To remove a node with given index:
model->removeRow(index.row(), index.parent());
koen
Updated by Francesco Alfano over 13 years ago
Thanks for your response, Francesco
Updated by Koen Deforche about 13 years ago
- Status changed from Feedback to Closed