PDA

View Full Version : How to group data in QTableView and show them in QTreeview ?



Fatemeh
12th May 2013, 17:54
Hi Dear,
I have a tableView on my form, that contain data from database.
I want to group data and show grouped data in a treeView, but i don't know how to do it !!
Is there anybody help me ?

Thanks a lot...

wysota
12th May 2013, 18:41
Qt does not provide any built-in methods for aggregating data. Therefore you need to execute an sql query that will return aggregated data and build the tree model from it by yourself. If you sort incoming data by groups, then while iterating the result set, you can check whether the group of the current record is the same as that from the previous record and build your nodes based on that.

Fatemeh
13th May 2013, 06:35
Thank you...
but i get data from database by query and don't have problem with it, i only don't know how do group data and put grouped data in QtreeView.
I searched and found that could use of QAbstractitemmodel & QTreeView for grouping data !! but i don't know how !!?
do you know how do i can use them ?

thanks...

wysota
13th May 2013, 09:53
but i get data from database by query and don't have problem with it, i only don't know how do group data and put grouped data in QtreeView.
By changing your query and building a tree model from the result.

Fatemeh
13th May 2013, 13:59
thank you very much for replies,
If it's possible please explain to me more about it, i'm beginner with Qt so i'm don't know how do it !!

Best regards...

wysota
13th May 2013, 14:47
What is the part that you don't know how to implement?