PDA

View Full Version : How to set QTreeView from an XML file?



MathFurious
13th April 2018, 19:11
Hi,

I want to set QTreeView model from an XML file? I tried with Qt exemples but they are for QTreeWidget, I did not succeed to convert one of exemple to work with QTreeView(with model).

I have an XML file like below.



<root>
<Folder Name="myFolder">
<File Name="myFile" />
</Folder>
<Folder Name="mySecondFolder">
<File Name="myFile2" />
<File Name="myFile3" />
<File Name="myFile4" />
</Folder>
</root>

d_stranz
13th April 2018, 19:41
I think this example (https://doc.qt.io/qt-5/qtwidgets-itemviews-simpledommodel-example.html) from the Qt distribution is what you need. The XML you showed above is not a properly complete XML document; it is missing the XML header information, so the DOM parser will probably reject it. Be sure you have a correct XML file.

MathFurious
13th April 2018, 20:07
I will try, thanks for reply.