PDA

View Full Version : Creating a Tree Model from a QStandardModel



kaushal_gaurav
17th December 2008, 06:27
Hi,

I need to create a tree model from an other model (QStandard Model).
The data is present in the QStandard model, the requirement is to create a tree in such a way that one of the columns of QStandard model is root of that tree.

Please guide to how can i do it.
If some sample code or some reference is provided, it would be great.

Regards,
GK

kaushal_gaurav
17th December 2008, 12:23
Any Ideas ???

jpn
18th December 2008, 16:47
I need to create a tree model from an other model (QStandard Model).
Luckily there is "an example usage of QStandardItemModel to create a tree" in QStandardItemModel docs.


The data is present in the QStandard model, the requirement is to create a tree in such a way that one of the columns of QStandard model is root of that tree.
Could you elaborate? How could one column be a root?

kaushal_gaurav
19th December 2008, 07:47
By one column has to be root i mean that...

The hierarchy goes as follows///
One of the column is Manufacturer... it would have many types of devices.. and then each type of device would have further substypes... for eg....

Manufacturer-----Device--------- Product
---------------------------------------------------------
HP-----------------Printer------------Inkjet
----------------------------------------Laser
--------------------Camera-----------Digital
----------------------------------------Analog

Cannon-------------Printer------------Inkjet
----------------------------------------Laser
---------------------Camera-----------Digital
----------------------------------------Analog

Other----------------Printer------------Inkjet
------------------------------------------Laser
----------------------Camera-----------Digital
------------------------------------------Analog

So here Manufacturer column is root so when user selected an item from Manufacturer column then the Devices column is branched and so on...
It is similar to MAC Finder window.....
I need to create a Tree Model and i am totally blank on how to proceed.......

Please help
GK