10-24-2012 05:03 PM
<root>
<header title="Frutas"> //nivel 1
<sample name="Manzana" icon= "manzana.png"> //nivel 2
<description text="la manzana es roja" infoText="Manzana"/> // nivel3
</sample>
<sample name="Cereza" icon= "cereza.png">
<description text="la cereza es vinotinto" infoText="Cereza"/>
</sample>
<sample name="Pera" icon= "pera.png">
<description text="la pera es verde" infoText="Pera" />
</sample>
</header>
<header title="Vegetales"> //nivel 1
<sample name="zanahoria" icon= "zanahoria.png"> //nivel 2
<description text="la zanahoria es naranja" infoText="zanahoria"/> // nivel3
</sample>
<sample name="ajo" icon= "ajo.png">
<description text="el ajo es blanco" infoText="ajo"/>
</sample>
<sample name="broccoli" icon= "brocolli.png">
<description text="el broccoli es verde" infoText="brocolli" />
</sample>
</header>
</root>
This is my XML
I want to create a list that shows the first class I bone
frutas
vegetales
to just click on any of them, show me another list with the second level of each, if I press vegetales, show me a list:
zanahoria
ajo
brocolli
and if I press any of these items show me another screen with the third level, I mean with the description of each, if pressed zanahoria show me:
la zanahoria es naranja.
I have reviewed many examples, I've read the documentation and nowhere tells me how to do this, all XML examples are linear with a single level. greatly appreciate the help is urgent.
10-24-2012 08:09 PM
you can look at this KB article, it shows how to build something similar to an 'accordion'...i'm pretty sure you should be able to modify such that it works as a collapsible list (assuming that is what you were looking for)...
for the xml, you will need to manually parse it (i used QDomDocument,... which is built into Qt), then insert this data in the list's datamodel. for the third level, simply insert the description as an attribute that you can retrieve when you click on a ListItem.
in a nutshell, you have to implement:
1) your own DataModel
2) custom code to parse that XML
The rest should be easy if you went through the ListView tutorials.
10-25-2012 09:06 AM
Thanks for your help, but could you give me an example of all that you say ..?
please.