
Originally Posted by
^NyAw^
Wrap the internal structure to a model is to get a model and my structure in parallel?
QAbstractItemModel subclass would itself keep no data at all. It would be a plain interface for to your internal data. That's how Qt's view classes would be able to represent your internal data without need of copying the internal data to another structure, QTreeWidgetItems in your case.

Originally Posted by
^NyAw^
Yes, I have LinkedLists that have internal nodes with uniques ID for each node.
Really I don't know wich is the best solution because my internal structure is handcoded (I had coded linkedLists, nodes, ... manually because it was done before I discovered Qt).
So basically you could mark each QTreeWidgetItem with corresponding identifier:
int id = ... // id of the corresponding item in the internal data structure
item->setData(0, Qt::UserRole, id);
int id = ... // id of the corresponding item in the internal data structure
item->setData(0, Qt::UserRole, id);
To copy to clipboard, switch view to plain text mode
And once you react to clicked-signal you could ask for the identifier:
int id = item->data(0, Qt::UserRole).toInt();
... // find the corresponding item in the internal data structure with help of id
int id = item->data(0, Qt::UserRole).toInt();
... // find the corresponding item in the internal data structure with help of id
To copy to clipboard, switch view to plain text mode
Roles starting from Qt::UserRole and upwards can be used for application specific things. QTreeWidgetItem will be able to store them, but will of course use them for nothing by itself.
Bookmarks