PDA

View Full Version : TreeModel from TableModel



baray98
18th May 2011, 23:56
I need to create a tree model with the following req's


this tree model will have a flat table source (QAbstractTableModel)
hierarchy will be based on the sort columns
at the end of the day a QTreeView and this model will behave exactly like the new Outlook 2010 Inbox list , when the user click sort by date a tree will be presented grouped by date


I am thinking is a job for a QSortFilterProxyModel and a CustomTreeModel that will goup things according to QSortFilterProxyModel::sortColumn and convert it into a tree in the QTreeView points of View.

Is there any other good suggestions out there?

baray98

wysota
19th May 2011, 01:17
QSortFilterProxyModel will not work as it cannot move an item to a different parent. You need to implement your own subclass of QAbstractProxyModel.

baray98
21st May 2011, 00:58
CustomTreeModel will come handy which inherits QAbstractItemModel to wrap around the sortfilter model. The sort filter model will be used only for sorting and giving the sortColumn in which the grouping will be based upon..

-baray98-

wysota
21st May 2011, 01:06
It needs to be done the other way round. The sort filter proxy model needs to wrap the tree (proxy) model. Otherwise sorting will not take into consideration the parent-child relationship of items.