Mapping a dom tree to a table and back.
-
I have a table view which displays parts of a DOM tree. Now to display I travel the tree and put the text to display into a grid, which is then displayed using a QAbstractTableModel. I want to make the table editable: After editing the table I need to find the DOM element which corresponds to the cell edited and update its content. I wonder what is the way to do this. Do QObjects, QDomNodes or QDomElements have some kind of unique identifier which I could use to keep track to them? Shall I use a pointer to the QDOMNodes or just store the position where in the QDomNodeLists they are?
-
Hi,
first, it makes no sense to make a QDomNode a QObject. QDomNodes are simple data structures, QObject would be an unneeded overhead.
How you reference the object is up to you. If the path to the object is unique, so no two elements with a similar path may exist, the path would be an option. But in xml, this is not required.
Using a pointer would also be an option.
-
Thanks for your answer. I just read up about the way QDomNode is implemented. It just holds a pointer to a private implementation class [1]! So I just need to keep a copy of a QDomNode.
[1] "qdom.h":http://iguana.web.cern.ch/iguana/lxr/source/Qt/qdom.h, line 222