PDA

View Full Version : creating a tree hierarchy using QStandardModel



wind
19th September 2006, 16:29
I have a XML file with the following structure:


<?xml version="1.0" encoding="utf-8"?>
<isl_project_command>
<task>
<code>root</code>
<parent_code></parent_code>
<start_date>date</start_date>
</task>
<task>
<code>child1</code>
<parent_code>root</parent_code>
<start_date>date</start_date>
</task>
<task>
<code>child1.1</code>
<parent_code>child1</parent_code>
<start_date>date</start_date>
</task>
</isl_project_command>


Now i try to build a QStandardModel of this structure for displaying data in a QTreeView.
The problem is i don't know how to create a hierarchy tree of the data.

The tree should look something like this: http://files.lagoji.si/w2.PNG

wysota
19th September 2006, 17:52
There is an example in QStandardItemModel docs how to build a tree using it. You can also search the forum here, I gave an example code to build a tree hierarchy using that model today.

jpn
19th September 2006, 17:58
And you want us to...? What have you tried so far?
Tips:
- search the forums, there's example pieces of code here and there
- check the examples provided with Qt (examples/itemviews)
- read QStandardItemModel docs once more (especially the detailed description part where's an example how to create a tree) ;)

Edit: the race is hard... yet another lose today :p

Valheru
19th September 2006, 22:54
Edit: the race is hard... yet another lose today :p

I wouldn't say that, it was your code that finally helped me to understand how the whole model/view thing works :)