Project

General

Profile

Actions

Support #957

closed

Modify node in wtreeview

Added by Francesco Alfano over 12 years ago. Updated over 12 years ago.

Status:
Closed
Priority:
High
Assignee:
Target version:
-
Start date:
08/16/2011
Due date:
% Done:

0%

Estimated time:

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.

Actions #1

Updated by Francesco Alfano over 12 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?

Actions #2

Updated by Koen Deforche over 12 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

Actions #3

Updated by Francesco Alfano over 12 years ago

Thanks, for your response.

Could you give me an example code ?

how can i remove that node ?

Thanks, Francesco

Actions #4

Updated by Koen Deforche over 12 years ago

Hey Fransesco,

To remove a node with given index:

model->removeRow(index.row(), index.parent());

koen

Actions #5

Updated by Francesco Alfano over 12 years ago

Thanks for your response, Francesco

Actions #6

Updated by Koen Deforche over 12 years ago

  • Status changed from Feedback to Closed
Actions

Also available in: Atom PDF