Connect QDomNode with QStandardItem

104 Views Asked by At

So im working on simple xml reader, and i want to show xml on the tree.

So to get iformation about which item on the tree is wich item in xml file i made a QMap:

QMap<QDomNode*,QStandardItem*> connectDomNodeAndStandardItem;

but it seems that QDomNode create whole new structure of objects when I use any of its method:

QDomNode *node = &_xmlDocument.firstChild();
qDebug() << node;
node = &node->firstChild();
qDebug() << &node->parentNode();

Output:

0x41be60
0x41be28

So my question is - How i can connect QDomNode with QStandardItem

1

There are 1 best solutions below

0
On BEST ANSWER

QDomeNode is a class that uses explicit sharing. That means all copies of the same node operate on same data. So you don't have to use pointers. And the reason for the different address is because QDomNode::parentNode returns a copy of the parent.