TreeView Content from 2 XML Files
-
Is it possible to create the Parent Node in TreeView from one XML File and add the children from another XML File?
@QtisHard said in TreeView Content from 2 XML Files:
Is it possible to create the Parent Node in TreeView from one XML File and add the children from another XML File?
Yes because you create the model and therefore can do whatever you want.
-
Is it possible to create the Parent Node in TreeView from one XML File and add the children from another XML File?
@QtisHard
As @Christian-Ehrlicher says, but note it's because you aren't actually having theQTreeView
's model be the XML, only whatever you did with it to get it into some model you are using. If you usedQDomDocument
as your internal model you wouldn't be able to add nodes from one XML document directly into a different one. -
Yes I used QDomDocument for creating the model that I am bounding to the treeview.
https://forum.qt.io/topic/138614/treeview-content-with-common-parent-and-different-children
This is what I am trying to achieve.I thought if I put the values in different XML files it might work out. However it seems that it wont.
Please guide me as to how I should proceed with this
-
Yes I used QDomDocument for creating the model that I am bounding to the treeview.
https://forum.qt.io/topic/138614/treeview-content-with-common-parent-and-different-children
This is what I am trying to achieve.I thought if I put the values in different XML files it might work out. However it seems that it wont.
Please guide me as to how I should proceed with this
@QtisHard
I only know from experience with XML documents. You have to import nodes from a different XML document if you want them, which is effectively copying them, not just using/pointing to them. ForQDomDocument
I would expect to have to use QDomNode QDomDocument::importNode(const QDomNode &importedNode, bool deep), which I think you should read/apply.This is all supposing you want a valid, full
QDocument
for your model. As @Christian-Ehrlicher says, since theQTreeView
only actually recognises/uses aQAbstractItemModel
you can do what you like behind the scenes to supply that in your own way from multiple XML files (not oneQDomDocument
) if you wish.